소스 검색

check number of socks servers

Darien Raymond 8 년 전
부모
커밋
ac8d882a55
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      proxy/socks/client.go

+ 5 - 3
proxy/socks/client.go

@@ -27,11 +27,13 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
 	for _, rec := range config.Server {
 		serverList.AddServer(protocol.NewServerSpecFromPB(*rec))
 	}
-	client := &Client{
-		serverPicker: protocol.NewRoundRobinServerPicker(serverList),
+	if serverList.Size() == 0 {
+		return nil, newError("0 target server")
 	}
 
-	return client, nil
+	return &Client{
+		serverPicker: protocol.NewRoundRobinServerPicker(serverList),
+	}, nil
 }
 
 // Process implements proxy.Outbound.Process.