Skip to content

Commit

Permalink
fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Jan 2, 2018
1 parent 30f2770 commit 9ccdf67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions transport/internet/tcp/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions transport/internet/tcp/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ 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
config *Config
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(),
Expand All @@ -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,
Expand All @@ -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():
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 9ccdf67

Please sign in to comment.