1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00

fix lint warnings

This commit is contained in:
Darien Raymond 2018-01-02 18:57:22 +01:00
parent 30f27706e0
commit 9ccdf67d2d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 11 additions and 6 deletions

View File

@ -17,6 +17,7 @@ func getTCPSettingsFromContext(ctx context.Context) *Config {
return rawTCPSettings.(*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) { func Dial(ctx context.Context, dest net.Destination) (internet.Connection, error) {
newError("dialing TCP to ", dest).WriteToLog() newError("dialing TCP to ", dest).WriteToLog()
src := internet.DialerSourceFromContext(ctx) src := internet.DialerSourceFromContext(ctx)

View File

@ -11,7 +11,8 @@ import (
"v2ray.com/core/transport/internet/tls" "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 listener *net.TCPListener
tlsConfig *gotls.Config tlsConfig *gotls.Config
authConfig internet.ConnectionAuthenticator authConfig internet.ConnectionAuthenticator
@ -19,6 +20,7 @@ type TCPListener struct {
addConn internet.AddConnection 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) { func ListenTCP(ctx context.Context, address net.Address, port net.Port, addConn internet.AddConnection) (internet.Listener, error) {
listener, err := net.ListenTCP("tcp", &net.TCPAddr{ listener, err := net.ListenTCP("tcp", &net.TCPAddr{
IP: address.IP(), IP: address.IP(),
@ -31,7 +33,7 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, addConn
networkSettings := internet.TransportSettingsFromContext(ctx) networkSettings := internet.TransportSettingsFromContext(ctx)
tcpSettings := networkSettings.(*Config) tcpSettings := networkSettings.(*Config)
l := &TCPListener{ l := &Listener{
listener: listener, listener: listener,
config: tcpSettings, config: tcpSettings,
addConn: addConn, addConn: addConn,
@ -52,11 +54,11 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, addConn
} }
l.authConfig = auth l.authConfig = auth
} }
go l.KeepAccepting(ctx) go l.keepAccepting(ctx)
return l, nil return l, nil
} }
func (v *TCPListener) KeepAccepting(ctx context.Context) { func (v *Listener) keepAccepting(ctx context.Context) {
for { for {
select { select {
case <-ctx.Done(): 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() return v.listener.Addr()
} }
func (v *TCPListener) Close() error { // Close implements internet.Listener.Close.
func (v *Listener) Close() error {
return v.listener.Close() return v.listener.Close()
} }