This commit is contained in:
Darien Raymond
2018-10-18 09:25:58 +02:00
parent be56feead3
commit 4fcb39ded9
8 changed files with 31 additions and 16 deletions
+7
View File
@@ -9,16 +9,21 @@ option java_multiple_files = true;
import "v2ray.com/core/common/net/address.proto";
import "v2ray.com/core/common/protocol/server_spec.proto";
// Account represents a Socks account.
message Account {
string username = 1;
string password = 2;
}
// AuthType is the authentication type of Socks proxy.
enum AuthType {
// NO_AUTH is for anounymous authentication.
NO_AUTH = 0;
// PASSWORD is for username/password authentication.
PASSWORD = 1;
}
// ServerConfig is the protobuf config for Socks server.
message ServerConfig {
AuthType auth_type = 1;
map<string, string> accounts = 2;
@@ -28,6 +33,8 @@ message ServerConfig {
uint32 user_level = 6;
}
// ClientConfig is the protobuf config for Socks client.
message ClientConfig {
// Sever is a list of Socks server addresses.
repeated v2ray.core.common.protocol.ServerEndpoint server = 1;
}
+6 -5
View File
@@ -24,22 +24,23 @@ import (
// Server is a SOCKS 5 proxy server
type Server struct {
config *ServerConfig
v *core.Instance
config *ServerConfig
policyManager policy.Manager
}
// NewServer creates a new Server object.
func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
v := core.MustFromContext(ctx)
s := &Server{
config: config,
v: core.MustFromContext(ctx),
config: config,
policyManager: v.PolicyManager(),
}
return s, nil
}
func (s *Server) policy() policy.Session {
config := s.config
p := s.v.PolicyManager().ForLevel(config.UserLevel)
p := s.policyManager.ForLevel(config.UserLevel)
if config.Timeout > 0 {
features.PrintDeprecatedFeatureWarning("Socks timeout")
}