用户代理通道超时关闭(暂时跳过认证)
This commit is contained in:
@@ -21,6 +21,12 @@ type AuthContext struct {
|
||||
}
|
||||
|
||||
func CheckIp(conn net.Conn) (*AuthContext, error) {
|
||||
return &AuthContext{
|
||||
Timeout: 0,
|
||||
Payload: Payload{
|
||||
1,
|
||||
},
|
||||
}, nil
|
||||
|
||||
// 获取用户地址
|
||||
remoteAddr := conn.RemoteAddr().String()
|
||||
@@ -74,6 +80,12 @@ func CheckIp(conn net.Conn) (*AuthContext, error) {
|
||||
}
|
||||
|
||||
func CheckPass(conn net.Conn, username, password string) (*AuthContext, error) {
|
||||
return &AuthContext{
|
||||
Timeout: 0,
|
||||
Payload: Payload{
|
||||
1,
|
||||
},
|
||||
}, nil
|
||||
|
||||
// 查询通道配置
|
||||
var channel models.Channel
|
||||
|
||||
@@ -4,9 +4,36 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ConnMap struct {
|
||||
_map sync.Map
|
||||
}
|
||||
|
||||
func (c *ConnMap) LoadAndDelete(key string) (*Conn, bool) {
|
||||
_value, ok := c._map.LoadAndDelete(key)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
return _value.(*Conn), true
|
||||
}
|
||||
|
||||
func (c *ConnMap) Store(key string, value *Conn) {
|
||||
c._map.Store(key, value)
|
||||
}
|
||||
|
||||
func (c *ConnMap) Range(f func(key string, value *Conn) bool) {
|
||||
c._map.Range(func(key, value any) bool {
|
||||
return f(key.(string), value.(*Conn))
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ConnMap) Clear() {
|
||||
c._map.Clear()
|
||||
}
|
||||
|
||||
type Conn struct {
|
||||
Conn net.Conn
|
||||
Reader *bufio.Reader
|
||||
|
||||
Reference in New Issue
Block a user