MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / NewClientConn

Function NewClientConn

internal/nodes/client_conn.go:55–91  ·  view source on GitHub ↗
(rawConn net.Conn, isHTTP bool, isTLS bool, isInAllowList bool)

Source from the content-addressed store, hash-verified

53}
54
55func NewClientConn(rawConn net.Conn, isHTTP bool, isTLS bool, isInAllowList bool) net.Conn {
56 // 是否为环路
57 var remoteAddr = rawConn.RemoteAddr().String()
58
59 var conn = &ClientConn{
60 BaseClientConn: BaseClientConn{rawConn: rawConn},
61 isTLS: isTLS,
62 isHTTP: isHTTP,
63 isLO: strings.HasPrefix(remoteAddr, "127.0.0.1:") || strings.HasPrefix(remoteAddr, "[::1]:"),
64 isNoStat: connutils.IsNoStatConn(remoteAddr),
65 isInAllowList: isInAllowList,
66 createdAt: fasttime.Now().Unix(),
67 }
68
69 if existsLnNodeIP(conn.RawIP()) {
70 conn.SetIsPersistent(true)
71 }
72
73 // 超时等设置
74 var globalServerConfig = sharedNodeConfig.GlobalServerConfig
75 if globalServerConfig != nil {
76 var performanceConfig = globalServerConfig.Performance
77 conn.isDebugging = performanceConfig.Debug
78 conn.autoReadTimeout = performanceConfig.AutoReadTimeout
79 conn.autoWriteTimeout = performanceConfig.AutoWriteTimeout
80 }
81
82 if isHTTP {
83 // TODO 可以在配置中设置此值
84 _ = conn.SetLinger(nodeconfigs.DefaultTCPLinger)
85 }
86
87 // 加入到Map
88 conns.SharedMap.Add(conn)
89
90 return conn
91}
92
93func (this *ClientConn) Read(b []byte) (n int, err error) {
94 if this.isDebugging {

Callers 1

AcceptMethod · 0.85

Calls 9

NowFunction · 0.92
existsLnNodeIPFunction · 0.85
UnixMethod · 0.80
RawIPMethod · 0.80
SetIsPersistentMethod · 0.65
SetLingerMethod · 0.65
AddMethod · 0.65
StringMethod · 0.45
RemoteAddrMethod · 0.45

Tested by

no test coverage detected