mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05:00
fix lint warnings
This commit is contained in:
parent
30f27706e0
commit
9ccdf67d2d
@ -17,6 +17,7 @@ func getTCPSettingsFromContext(ctx context.Context) *Config {
|
||||
return rawTCPSettings.(*Config)
|
||||
}
|
||||
|
||||
// Dial dials a new TCP connection to the given destination.
|
||||
func Dial(ctx context.Context, dest net.Destination) (internet.Connection, error) {
|
||||
newError("dialing TCP to ", dest).WriteToLog()
|
||||
src := internet.DialerSourceFromContext(ctx)
|
||||
|
@ -11,7 +11,8 @@ import (
|
||||
"v2ray.com/core/transport/internet/tls"
|
||||
)
|
||||
|
||||
type TCPListener struct {
|
||||
// Listener is an internet.Listener that listens for TCP connections.
|
||||
type Listener struct {
|
||||
listener *net.TCPListener
|
||||
tlsConfig *gotls.Config
|
||||
authConfig internet.ConnectionAuthenticator
|
||||
@ -19,6 +20,7 @@ type TCPListener struct {
|
||||
addConn internet.AddConnection
|
||||
}
|
||||
|
||||
// ListenTCP creates a new Listener based on configurations.
|
||||
func ListenTCP(ctx context.Context, address net.Address, port net.Port, addConn internet.AddConnection) (internet.Listener, error) {
|
||||
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
|
||||
IP: address.IP(),
|
||||
@ -31,7 +33,7 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, addConn
|
||||
networkSettings := internet.TransportSettingsFromContext(ctx)
|
||||
tcpSettings := networkSettings.(*Config)
|
||||
|
||||
l := &TCPListener{
|
||||
l := &Listener{
|
||||
listener: listener,
|
||||
config: tcpSettings,
|
||||
addConn: addConn,
|
||||
@ -52,11 +54,11 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, addConn
|
||||
}
|
||||
l.authConfig = auth
|
||||
}
|
||||
go l.KeepAccepting(ctx)
|
||||
go l.keepAccepting(ctx)
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func (v *TCPListener) KeepAccepting(ctx context.Context) {
|
||||
func (v *Listener) keepAccepting(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@ -88,11 +90,13 @@ func (v *TCPListener) KeepAccepting(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (v *TCPListener) Addr() net.Addr {
|
||||
// Addr implements internet.Listener.Addr.
|
||||
func (v *Listener) Addr() net.Addr {
|
||||
return v.listener.Addr()
|
||||
}
|
||||
|
||||
func (v *TCPListener) Close() error {
|
||||
// Close implements internet.Listener.Close.
|
||||
func (v *Listener) Close() error {
|
||||
return v.listener.Close()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user