From d76e8245e0c089201d48fcbd6fc6977dde1cce1b Mon Sep 17 00:00:00 2001 From: elisaveta9 Date: Fri, 26 Dec 2025 19:54:07 +0300 Subject: [PATCH] small fix --- admin.log | 16 ++++++ admin/admin.html | 127 --------------------------------------------- admin/handlers.go | 22 +++++--- device/device.go | 2 +- ingress/handler.go | 2 +- 5 files changed, 33 insertions(+), 136 deletions(-) delete mode 100644 admin/admin.html diff --git a/admin.log b/admin.log index 0ef0eea..3cc63b6 100644 --- a/admin.log +++ b/admin.log @@ -20,3 +20,19 @@ 2025/12/22 20:35:10 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:57431 2025/12/23 13:11:21 ADMIN ADD domain=api.phone.local ip=192.168.31.108:51617 2025/12/23 13:16:27 ADMIN ADD domain=api.phone.key ip=192.168.31.108:51942 +2025/12/23 13:59:39 ADMIN ADD domain=api.phone.local ip=192.168.31.108:54219 +2025/12/24 11:09:00 ADMIN AUTH_MISSING ip=127.0.0.1:62049 +2025/12/24 11:09:18 ADMIN ADD domain=api.phone.local ip=127.0.0.1:62049 +2025/12/24 11:46:22 ADMIN ADD domain=photo.phone.local ip=192.168.188.24:49477 +2025/12/24 12:04:15 ADMIN AUTH_MISSING ip=192.168.188.24:54980 +2025/12/24 16:27:27 ADMIN ADD domain=api.phone.local ip=192.168.31.108:54824 +2025/12/24 16:35:37 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:54824 +2025/12/26 08:07:58 ADMIN DELETE domain=photo.phone.local ip=192.168.31.108:50958 +2025/12/26 08:08:55 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:50958 +2025/12/26 08:22:28 ADMIN ADD domain=api.phone.local ip=192.168.31.108:51483 +2025/12/26 08:22:40 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:51483 +2025/12/26 08:25:35 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:51483 +2025/12/26 16:44:18 ADMIN ADD domain=api.phone.local ip=192.168.31.108:49806 +2025/12/26 16:44:27 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:49806 +2025/12/26 16:46:39 ADMIN ADD domain=api.phone.local ip=192.168.31.108:49877 +2025/12/26 16:46:49 ADMIN ADD domain=photo.phone.local ip=192.168.31.108:49877 diff --git a/admin/admin.html b/admin/admin.html deleted file mode 100644 index ffa5edd..0000000 --- a/admin/admin.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - Relay Admin Panel - - - - -

Relay Admin Panel

- - - -
- -

Registered domains

- - - -
- -

Add domain

- - - -

- - - - - \ No newline at end of file diff --git a/admin/handlers.go b/admin/handlers.go index ed63a98..590e4c6 100644 --- a/admin/handlers.go +++ b/admin/handlers.go @@ -4,6 +4,8 @@ import ( "net/http" "strings" + "relay/device" + tunnelpb "relay/proto/tunnel" "relay/registry" ) @@ -40,19 +42,25 @@ func domainsHandler(w http.ResponseWriter, r *http.Request) { case "DELETE": domain := strings.ToLower(r.URL.Query().Get("domain")) + var dev *device.Device + var existed bool + registry.Global.Mu.Lock() - if _, exists := registry.Global.Domains[domain]; exists { + if d, ok := registry.Global.Domains[domain]; ok { + existed = true + dev = d delete(registry.Global.Domains, domain) - adminLogger.Printf( - "ADMIN DELETE domain=%s ip=%s", - domain, r.RemoteAddr, - ) } registry.Global.Mu.Unlock() - w.Write([]byte("deleted\n")) + if existed && dev != nil { + dev.SendFrame(&tunnelpb.Frame{ + Type: tunnelpb.FrameType_FRAME_BIND_REJECTED, + Payload: []byte(domain), + }) + } default: - http.Error(w, "method not allowed", 405) + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) } } diff --git a/device/device.go b/device/device.go index 239d92e..87bcc87 100644 --- a/device/device.go +++ b/device/device.go @@ -23,7 +23,7 @@ type Device struct { func NewDevice(stream tunnelpb.TunnelService_TunnelServer) *Device { d := &Device{ stream: stream, - sendCh: make(chan *tunnelpb.Frame, 128), // backpressure here + sendCh: make(chan *tunnelpb.Frame, 128), done: make(chan struct{}), streams: make(map[uint32]net.Conn), streamDone: make(map[uint32]chan struct{}), diff --git a/ingress/handler.go b/ingress/handler.go index 065b868..7a87d99 100644 --- a/ingress/handler.go +++ b/ingress/handler.go @@ -35,7 +35,7 @@ func handleClientTCP(conn net.Conn) { streamID := dev.AllocateStreamID() done := dev.AddStream(streamID, conn) - log.Printf("Client [%s] → device (stream %d)\n", sni, streamID) + log.Printf("Client [%s] -> device (stream %d)\n", sni, streamID) dev.SendFrame(&tunnelpb.Frame{ Type: tunnelpb.FrameType_FRAME_OPEN,