fix: resolve nil pointer dereference in interaction on TLS request
This commit is contained in:
23
docker-compose.yaml
Normal file
23
docker-compose.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
services:
|
||||
tunnlpls:
|
||||
image: git.fossy.my.id/bagas/tunnl_please:staging
|
||||
ports:
|
||||
- 80:80
|
||||
- 2200:2200
|
||||
volumes:
|
||||
- ./certs:/certs
|
||||
# - /etc/letsencrypt/live/sgp.tunnl.live/fullchain.pem:/certs/fullchain.pem
|
||||
# - /etc/letsencrypt/live/sgp.tunnl.live/privkey.pem:/certs/privkey.pem
|
||||
labels:
|
||||
- "com.centurylinklabs.watchtower.enable=true"
|
||||
environment:
|
||||
domain: sgp.tunnl.live
|
||||
port: 2200
|
||||
tls_enabled: true
|
||||
tls_redirect: true
|
||||
cert_loc: /certs/localhost.direct.SS.crt
|
||||
key_loc: /certs/localhost.direct.SS.key
|
||||
ssh_private_key: /certs/id_rsa
|
||||
cors_list: https://tunnl.live
|
||||
ALLOWED_PORTS: 10000-50000
|
||||
restart: always
|
||||
@ -11,11 +11,13 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"tunnel_pls/session"
|
||||
"tunnel_pls/session/interaction"
|
||||
"tunnel_pls/types"
|
||||
"tunnel_pls/utils"
|
||||
)
|
||||
|
||||
type Interaction interface {
|
||||
SendMessage(message string)
|
||||
}
|
||||
type CustomWriter struct {
|
||||
RemoteAddr net.Addr
|
||||
writer io.Writer
|
||||
@ -24,13 +26,13 @@ type CustomWriter struct {
|
||||
buf []byte
|
||||
respHeader *ResponseHeaderFactory
|
||||
reqHeader *RequestHeaderFactory
|
||||
interaction interaction.Controller
|
||||
interaction Interaction
|
||||
respMW []ResponseMiddleware
|
||||
reqStartMW []RequestMiddleware
|
||||
reqEndMW []RequestMiddleware
|
||||
}
|
||||
|
||||
func (cw *CustomWriter) SetInteraction(interaction interaction.Controller) {
|
||||
func (cw *CustomWriter) SetInteraction(interaction Interaction) {
|
||||
cw.interaction = interaction
|
||||
}
|
||||
|
||||
@ -176,7 +178,7 @@ func (cw *CustomWriter) Write(p []byte) (int, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (cw *CustomWriter) AddInteraction(interaction *interaction.Interaction) {
|
||||
func (cw *CustomWriter) AddInteraction(interaction Interaction) {
|
||||
cw.interaction = interaction
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ func HandlerTLS(conn net.Conn) {
|
||||
return
|
||||
}
|
||||
cw := NewCustomWriter(conn, dstReader, conn.RemoteAddr())
|
||||
|
||||
cw.SetInteraction(sshSession.Interaction)
|
||||
forwardRequest(cw, reqhf, sshSession)
|
||||
return
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
"tunnel_pls/session/interaction"
|
||||
)
|
||||
|
||||
type RequestMiddleware interface {
|
||||
@ -29,20 +28,22 @@ func (h *TunnelFingerprint) HandleResponse(header *ResponseHeaderFactory, body [
|
||||
}
|
||||
|
||||
type RequestLogger struct {
|
||||
interaction interaction.Controller
|
||||
interaction Interaction
|
||||
remoteAddr net.Addr
|
||||
}
|
||||
|
||||
func NewRequestLogger(interaction interaction.Controller, remoteAddr net.Addr) *RequestLogger {
|
||||
func NewRequestLogger(interaction Interaction, remoteAddr net.Addr) *RequestLogger {
|
||||
return &RequestLogger{
|
||||
interaction: interaction,
|
||||
remoteAddr: remoteAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (rl *RequestLogger) HandleRequest(header *RequestHeaderFactory) error {
|
||||
rl.interaction.SendMessage(fmt.Sprintf("\033[32m%s %s -> %s %s \033[0m\r\n", time.Now().UTC().Format(time.RFC3339), rl.remoteAddr.String(), header.Method, header.Path))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rl *RequestLogger) HandleResponse(header *ResponseHeaderFactory, body []byte) error { return nil }
|
||||
|
||||
//TODO: Implement caching atau enggak
|
||||
|
||||
Reference in New Issue
Block a user