fix: create sever on each pconn

This commit is contained in:
Mingye Chen 2025-03-06 12:59:53 -07:00
parent ad1633e9fe
commit 8316deb144

View file

@ -37,7 +37,7 @@ func Oscur0Client(pconn net.PacketConn, addr net.Addr, oscur0Conf *Oscur0Config)
return econn, nil return econn, nil
} }
var baseServerMap map[string]*baseServer = map[string]*baseServer{} // var baseServerMap map[string]*baseServer = map[string]*baseServer{}
func Oscur0Server(pconn net.PacketConn, addr net.Addr, oscur0Conf *Oscur0Config) (Connection, error) { func Oscur0Server(pconn net.PacketConn, addr net.Addr, oscur0Conf *Oscur0Config) (Connection, error) {
keyLogWriter, err := os.Create("./server_keylog.txt") keyLogWriter, err := os.Create("./server_keylog.txt")
@ -50,17 +50,17 @@ func Oscur0Server(pconn net.PacketConn, addr net.Addr, oscur0Conf *Oscur0Config)
ConnectionIDLength: len(oscur0Conf.ClientConnID), ConnectionIDLength: len(oscur0Conf.ClientConnID),
} }
server, ok := baseServerMap[pconn.LocalAddr().String()] // server, ok := baseServerMap[pconn.LocalAddr().String()]
if !ok { // if !ok {
server, err = tp.createServer(&tls.Config{ server, err := tp.createServer(&tls.Config{
NextProtos: []string{"h3"}, NextProtos: []string{"h3"},
KeyLogWriter: keyLogWriter, KeyLogWriter: keyLogWriter,
}, &Config{}, true) }, &Config{}, true)
if err != nil { if err != nil {
return nil, err return nil, err
}
baseServerMap[pconn.LocalAddr().String()] = server
} }
// baseServerMap[pconn.LocalAddr().String()] = server
// }
return server.Oscur0Accept(addr, oscur0Conf) return server.Oscur0Accept(addr, oscur0Conf)
} }