base sagernet and migrate to circleci

This commit is contained in:
iceBear67
2026-07-16 04:47:12 +00:00
parent cf2658264a
commit 87871e223f
16 changed files with 322 additions and 149 deletions
+8 -8
View File
@@ -1,6 +1,6 @@
--- a/protocol/group/urltest.go
+++ b/protocol/group/urltest.go
@@ -39,6 +39,7 @@
@@ -37,6 +37,7 @@
connection adapter.ConnectionManager
logger log.ContextLogger
tags []string
@@ -8,7 +8,7 @@
link string
interval time.Duration
tolerance uint16
@@ -61,6 +62,7 @@
@@ -58,6 +59,7 @@
tolerance: options.Tolerance,
idleTimeout: time.Duration(options.IdleTimeout),
interruptExternalConnections: options.InterruptExistConnections,
@@ -16,7 +16,7 @@
}
if len(outbound.tags) == 0 {
return nil, E.New("missing tags")
@@ -77,7 +79,7 @@
@@ -74,7 +76,7 @@
}
outbounds = append(outbounds, detour)
}
@@ -25,7 +25,7 @@
if err != nil {
return err
}
@@ -194,6 +196,7 @@
@@ -175,6 +177,7 @@
pauseCallback *list.Element[pause.Callback]
logger log.Logger
outbounds []adapter.Outbound
@@ -33,7 +33,7 @@
link string
interval time.Duration
tolerance uint16
@@ -211,7 +214,7 @@
@@ -192,7 +195,7 @@
lastActive common.TypedValue[time.Time]
}
@@ -42,7 +42,7 @@
if interval == 0 {
interval = C.DefaultURLTestInterval
}
@@ -221,6 +224,11 @@
@@ -202,6 +205,11 @@
if idleTimeout == 0 {
idleTimeout = C.DefaultURLTestIdleTimeout
}
@@ -54,7 +54,7 @@
if interval > idleTimeout {
return nil, E.New("interval must be less or equal than idle_timeout")
}
@@ -237,6 +245,7 @@
@@ -214,6 +222,7 @@
outbound: outboundManager,
logger: logger,
outbounds: outbounds,
@@ -62,7 +62,7 @@
link: link,
interval: interval,
tolerance: tolerance,
@@ -392,7 +401,14 @@
@@ -374,7 +383,14 @@
g.logger.Debug("outbound ", tag, " unavailable: ", err)
g.history.DeleteURLTestHistory(realTag)
} else {
@@ -112,7 +112,7 @@
+ return h.fallbackAddr.IsValid()
+}
+
+func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) {
+func (h *Inbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) {
+ err := h.handleConnection(ctx, conn, metadata, onClose)
+ if err != nil && !E.IsClosed(err) {
+ h.logger.ErrorContext(ctx, E.Cause(err, "process connection from ", metadata.Source))
+1 -1
View File
@@ -117,7 +117,7 @@
+ )
+}
+
+func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) {
+func (h *Inbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) {
+ // Use go-mysql server to perform the MySQL handshake (which negotiates TLS)
+ mysqlConn, err := h.mysqlServer.NewCustomizedConn(conn, h.identityProvider, &emptyHandler{})
+ if err != nil {
@@ -163,8 +163,8 @@
+ )
+}
+
+// NewConnectionEx receives TCP connections from the listener and feeds them to the HTTP server.
+func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) {
+// NewConnection receives TCP connections from the listener and feeds them to the HTTP server.
+func (h *Inbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc) {
+ if h.tlsConfig != nil {
+ tlsConn, err := boxTLS.ServerHandshake(ctx, conn, h.tlsConfig)
+ if err != nil {
@@ -444,7 +444,7 @@
+ return hex.EncodeToString(b)
+}
+
+// connListener bridges the listener.Listener (which pushes connections via NewConnectionEx)
+// connListener bridges the listener.Listener (which pushes connections via NewConnection)
+// with http.Server.Serve() (which expects a net.Listener).
+type connListener struct {
+ ch chan net.Conn