Documentation ¶
Index ¶
- Constants
- func ChangeProxyNode() error
- func NewProxyPoolGrpcClient() (c g.ProxyPoolServiceClient, conn *grpc.ClientConn)
- func RequestProxyPoolGrpcOnce(h func(c g.ProxyPoolServiceClient, ctx context.Context))
- func RunProxyPoolGrpcServer()
- func RunServer()
- func SetProxy(proxy string) error
- type JsonConfig
- type ProxyNode
- type ProxyNodes
- type ProxyPool
- func (p *ProxyPool) ActiveNode(n ProxyNode, globalProxy bool) error
- func (p *ProxyPool) AddNode(n ProxyNode)
- func (p *ProxyPool) AddSpeedNode(key string, n ProxyNode)
- func (p *ProxyPool) AddV2rayServer(vs *V2rayServer) error
- func (p ProxyPool) CheckLocalPort(checkPorts []int) error
- func (p ProxyPool) CheckV2rayConfig(jconf JsonConfig) error
- func (p *ProxyPool) Delete(index int) error
- func (p *ProxyPool) DeleteV2rayServer(pid int) error
- func (p ProxyPool) GetActiveNode() ProxyNode
- func (p ProxyPool) GetLastSpeedNode(nd ProxyNode, d string) ProxyNode
- func (p ProxyPool) GetLocalAddr(n ProxyNode) string
- func (p ProxyPool) GetLocalPortList() (dl []int, err error)
- func (p ProxyPool) GetLocalPortRange() string
- func (p *ProxyPool) GetNodes(domain string) ProxyNodes
- func (p ProxyPool) GetTestedDomainList() []string
- func (p ProxyPool) GetV2rayServerList() []*V2rayServer
- func (p *ProxyPool) InitSubscribeData() *ProxyPool
- func (p *ProxyPool) KillAllNodes() (total, runport, kill, fail int)
- func (p *ProxyPool) RemoveNode(n ProxyNode)
- func (p *ProxyPool) SetLocalAddr(n *ProxyNode, port int) string
- func (p *ProxyPool) SetLocalPortStart(port int) *ProxyPool
- func (p *ProxyPool) SetSubscribeRawData(d string) *ProxyPool
- func (p *ProxyPool) SetSubscribeUrl(d string) *ProxyPool
- func (p *ProxyPool) SetTestMaxDuration(d time.Duration) *ProxyPool
- func (p *ProxyPool) SetTestUrl(turl string) *ProxyPool
- func (p *ProxyPool) SetV2rayPath(path string) *ProxyPool
- func (p *ProxyPool) StartAll() error
- func (p *ProxyPool) StartV2rayPool()
- func (p *ProxyPool) StopAll() error
- func (p *ProxyPool) TestAll()
- func (p *ProxyPool) TestAllForce()
- func (p *ProxyPool) UnActiveNode(n ProxyNode) error
- func (p *ProxyPool) UpdateAfterStopAll() (okcount, errcount int, err error)
- func (p *ProxyPool) UpdateNode(n ProxyNode) error
- func (p *ProxyPool) UpdateSubscribe(httpProxy string) (total, add int)
- type ProxyPoolServer
- func (s ProxyPoolServer) ActiveProxyNode(ctx context.Context, req *g.ProxyNode) (result *g.OptResult, err error)
- func (s ProxyPoolServer) GetProxyNodes(ctx context.Context, req *g.ProxyNode) (*g.ProxyNodes, error)
- func (s ProxyPoolServer) GetProxyNodesByDomain(ctx context.Context, req *g.OptRequestDomain) (*g.ProxyNodes, error)
- func (s ProxyPoolServer) KillAllNodes(ctx context.Context, req *g.OptRequest) (result *g.KillNodesResult, err error)
- func (s ProxyPoolServer) SetTestUrl(ctx context.Context, req *g.OptRequestUrl) (result *g.OptResult, err error)
- func (s ProxyPoolServer) StartProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
- func (s ProxyPoolServer) StopProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
- func (s ProxyPoolServer) TestProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
- func (s ProxyPoolServer) TestProxyPoolAllForce(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
- func (s ProxyPoolServer) UpdateProxySubscribe(ctx context.Context, req *g.OptRequest) (result *g.UpdateSubscribeResult, err error)
- type V2rayApiClient
- func (a V2rayApiClient) AddInbound(inport net.Port, intag, protocol string) error
- func (a V2rayApiClient) AddOutboundByV2rayNode(nd V2rayNode, outag string) error
- func (a *V2rayApiClient) Close()
- func (a *V2rayApiClient) Dial() error
- func (a V2rayApiClient) RemoveInbound(intag string) error
- func (a V2rayApiClient) RemoveOutbound(outag string) error
- type V2rayConfigV4
- type V2rayConfigV5
- type V2rayInbound
- type V2rayNode
- type V2rayOutbound
- type V2rayRouteRule
- type V2rayServer
- func (v V2rayServer) GetExeCmd() *exec.Cmd
- func (v V2rayServer) GetJsonConfig() JsonConfig
- func (v V2rayServer) GetLocalPort() int
- func (v V2rayServer) GetV2rayConfigV4() V2rayConfigV4
- func (v *V2rayServer) SetNode(n V2rayNode) *V2rayServer
- func (v *V2rayServer) SetPort(port int) *V2rayServer
- func (v *V2rayServer) Start(configFile string) error
Constants ¶
const MAX_TEST_DURATION = 5 * time.Second
节点测速最大超时设置。
const ROUTING_RULES_FILE = "routing.rules.json"
若存在,则优先读取。否则创建(v2raypool)
const TAG_INBOUND_API = "TAG_INBOUND_API"
const TAG_OUTBOUND_ACTIVE = "TAG_ACTIVE_OUTBOUND"
const TAG_OUTBOUND_API = "TAG_OUTBOUND_API"
const TAG_OUTBOUND_DIRECT = "DIRECT"
const V2RAYPOOL_CONFIG_FILE = "v2raypool.config.json"
const V2RAY_CONFIG_FILE = "v2ray.config.json"
只写文件,被 ROUTING_RULES_FILE 文件覆盖部分值(v2raypool)
Variables ¶
This section is empty.
Functions ¶
func NewProxyPoolGrpcClient ¶
func NewProxyPoolGrpcClient() (c g.ProxyPoolServiceClient, conn *grpc.ClientConn)
NewProxyPoolGrpcClient c, conn := NewProxyPoolGrpcClient() defer conn.Close() ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() nds, err := c.GetProxyNodes(ctx, &ProxyNode{IsRunning: true})
func RequestProxyPoolGrpcOnce ¶
func RequestProxyPoolGrpcOnce(h func(c g.ProxyPoolServiceClient, ctx context.Context))
func RunProxyPoolGrpcServer ¶
func RunProxyPoolGrpcServer()
Types ¶
type JsonConfig ¶ added in v1.3.0
type JsonConfig struct {
// contains filtered or unexported fields
}
func NewJsonConfig ¶ added in v1.3.0
func NewJsonConfig(b []byte) *JsonConfig
func NewJsonConfigFromFile ¶ added in v1.3.0
func NewJsonConfigFromFile(fpath string) *JsonConfig
func (JsonConfig) Decode ¶ added in v1.3.0
func (j JsonConfig) Decode(v any) error
func (JsonConfig) GetFilepath ¶ added in v1.3.0
func (j JsonConfig) GetFilepath() string
func (JsonConfig) Reader ¶ added in v1.3.0
func (j JsonConfig) Reader() io.Reader
func (*JsonConfig) SaveToFile ¶ added in v1.3.0
func (j *JsonConfig) SaveToFile(filepath string) error
SaveToFile 保存json内容到filepath文件。 若 filepath 为空,则保存到默认 filepath
func (*JsonConfig) SetContent ¶ added in v1.3.0
func (j *JsonConfig) SetContent(v any) error
func (JsonConfig) String ¶ added in v1.3.0
func (j JsonConfig) String() string
type ProxyNode ¶
type ProxyNode struct {
Index, LocalPort int
Id, LocalAddr string
RemoteAddr string `json:"remote_addr"`
Title, Protocol string
TestUrl string
Speed time.Duration
TestAt time.Time
V2rayNode V2rayNode
Status int
IsDelete bool
}
func NewProxyNodeByV2ray ¶
func (*ProxyNode) AddToPool ¶ added in v1.1.1
func (p *ProxyNode) AddToPool(c *V2rayApiClient) error
type ProxyNodes ¶
type ProxyNodes []ProxyNode
func GetRunningNodes ¶
func GetRunningNodes() ProxyNodes
func (ProxyNodes) Len ¶
func (s ProxyNodes) Len() int
func (ProxyNodes) Less ¶
func (s ProxyNodes) Less(i, j int) bool
func (*ProxyNodes) SortBySpeed ¶
func (s *ProxyNodes) SortBySpeed()
func (ProxyNodes) Swap ¶
func (s ProxyNodes) Swap(i, j int)
type ProxyPool ¶
type ProxyPool struct { IsLock bool // contains filtered or unexported fields }
func GetProxyPool ¶
func GetProxyPool() *ProxyPool
func NewProxyPool ¶
func NewProxyPool() *ProxyPool
func (*ProxyPool) ActiveNode ¶
ActiveNode 激活一个节点作为系统代理。会新建一个v2ray线程来监听系统代理的入站端口。 globalProxy: windows可自动设置系统代理。true使用代理池节点的入站端口。false使用新v2ray线程的系统代理入站端口。
func (*ProxyPool) AddSpeedNode ¶
func (*ProxyPool) AddV2rayServer ¶ added in v1.3.0
func (p *ProxyPool) AddV2rayServer(vs *V2rayServer) error
func (ProxyPool) CheckLocalPort ¶ added in v1.3.0
func (ProxyPool) CheckV2rayConfig ¶ added in v1.3.0
func (p ProxyPool) CheckV2rayConfig(jconf JsonConfig) error
CheckV2rayConfig 检查配置项。判断入站端口号是否被占用。
func (*ProxyPool) DeleteV2rayServer ¶ added in v1.3.0
func (ProxyPool) GetActiveNode ¶ added in v1.2.0
func (ProxyPool) GetLastSpeedNode ¶ added in v1.3.0
GetLastSpeedNode 查看当前节点是否存在测速信息
func (ProxyPool) GetLocalAddr ¶
func (ProxyPool) GetLocalPortList ¶ added in v1.3.0
func (ProxyPool) GetLocalPortRange ¶ added in v1.3.0
func (*ProxyPool) GetNodes ¶
func (p *ProxyPool) GetNodes(domain string) ProxyNodes
func (ProxyPool) GetTestedDomainList ¶ added in v1.3.0
func (ProxyPool) GetV2rayServerList ¶ added in v1.3.0
func (p ProxyPool) GetV2rayServerList() []*V2rayServer
func (*ProxyPool) InitSubscribeData ¶
func (*ProxyPool) KillAllNodes ¶
func (*ProxyPool) RemoveNode ¶
func (*ProxyPool) SetLocalPortStart ¶
func (*ProxyPool) SetSubscribeRawData ¶
func (*ProxyPool) SetSubscribeUrl ¶
func (*ProxyPool) SetTestMaxDuration ¶
func (*ProxyPool) SetTestUrl ¶
func (*ProxyPool) SetV2rayPath ¶
func (*ProxyPool) StartV2rayPool ¶ added in v1.3.0
func (p *ProxyPool) StartV2rayPool()
func (*ProxyPool) TestAllForce ¶
func (p *ProxyPool) TestAllForce()
func (*ProxyPool) UnActiveNode ¶ added in v1.2.0
func (*ProxyPool) UpdateAfterStopAll ¶
func (*ProxyPool) UpdateNode ¶
func (*ProxyPool) UpdateSubscribe ¶
type ProxyPoolServer ¶
type ProxyPoolServer struct {
g.UnimplementedProxyPoolServiceServer
}
func (ProxyPoolServer) ActiveProxyNode ¶
func (ProxyPoolServer) GetProxyNodes ¶
func (s ProxyPoolServer) GetProxyNodes(ctx context.Context, req *g.ProxyNode) (*g.ProxyNodes, error)
func (ProxyPoolServer) GetProxyNodesByDomain ¶
func (s ProxyPoolServer) GetProxyNodesByDomain(ctx context.Context, req *g.OptRequestDomain) (*g.ProxyNodes, error)
func (ProxyPoolServer) KillAllNodes ¶
func (s ProxyPoolServer) KillAllNodes(ctx context.Context, req *g.OptRequest) (result *g.KillNodesResult, err error)
func (ProxyPoolServer) SetTestUrl ¶
func (s ProxyPoolServer) SetTestUrl(ctx context.Context, req *g.OptRequestUrl) (result *g.OptResult, err error)
func (ProxyPoolServer) StartProxyPoolAll ¶
func (s ProxyPoolServer) StartProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
func (ProxyPoolServer) StopProxyPoolAll ¶
func (s ProxyPoolServer) StopProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
func (ProxyPoolServer) TestProxyPoolAll ¶
func (s ProxyPoolServer) TestProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
func (ProxyPoolServer) TestProxyPoolAllForce ¶
func (s ProxyPoolServer) TestProxyPoolAllForce(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)
func (ProxyPoolServer) UpdateProxySubscribe ¶
func (s ProxyPoolServer) UpdateProxySubscribe(ctx context.Context, req *g.OptRequest) (result *g.UpdateSubscribeResult, err error)
type V2rayApiClient ¶ added in v1.1.1
type V2rayApiClient struct {
// contains filtered or unexported fields
}
func NewV2rayApiClientV5 ¶ added in v1.1.1
func NewV2rayApiClientV5(addr string) *V2rayApiClient
func (V2rayApiClient) AddInbound ¶ added in v1.1.1
func (a V2rayApiClient) AddInbound(inport net.Port, intag, protocol string) error
AddInbound 添加入站规则 protocol http|socks
func (V2rayApiClient) AddOutboundByV2rayNode ¶ added in v1.1.1
func (a V2rayApiClient) AddOutboundByV2rayNode(nd V2rayNode, outag string) error
func (*V2rayApiClient) Close ¶ added in v1.1.1
func (a *V2rayApiClient) Close()
func (*V2rayApiClient) Dial ¶ added in v1.1.1
func (a *V2rayApiClient) Dial() error
func (V2rayApiClient) RemoveInbound ¶ added in v1.1.1
func (a V2rayApiClient) RemoveInbound(intag string) error
func (V2rayApiClient) RemoveOutbound ¶ added in v1.1.1
func (a V2rayApiClient) RemoveOutbound(outag string) error
type V2rayConfigV4 ¶
type V2rayConfigV4 struct { Log json.RawMessage `json:"log"` Api json.RawMessage `json:"api"` // Dns json.RawMessage `json:"dns"` Routing json.RawMessage `json:"routing"` Inbounds []V2rayInbound `json:"inbounds"` Outbounds []V2rayOutbound `json:"outbounds"` }
type V2rayConfigV5 ¶
type V2rayConfigV5 struct { Log json.RawMessage `json:"log"` Dns json.RawMessage `json:"dns"` Router json.RawMessage `json:"router"` Inbounds []V2rayInbound `json:"inbounds"` Outbounds []V2rayOutbound `json:"outbounds"` Services map[string]json.RawMessage `json:"services"` Extensions []json.RawMessage `json:"extension"` }
type V2rayInbound ¶
type V2rayInbound struct { Protocol string Port int Listen string // 默认值为 "0.0.0.0" Tag string // 此入站连接的标识,用于在其它的配置中定位此连接。当其不为空时,其值必须在所有 tag 中唯一。 Settings json.RawMessage `json:"settings"` // {"auth":"noauth","udp":true,"ip":"%s"} }
v4 {"port":%d,"listen":"%s","protocol":"http","settings":{"auth":"noauth","udp":true,"ip":"%s"}}
func NewV2rayInboundV4 ¶ added in v1.4.1
func NewV2rayInboundV4(proto string, inPort int) V2rayInbound
type V2rayNode ¶
type V2rayNode struct {
Protocol, Add, Host, Id, Net, Path, Ps, Tls, Type string
V, Aid, Port json.Number
}
"protocol":"vmess"
type V2rayOutbound ¶
type V2rayOutbound struct { Protocol string `json:"protocol"` SendThrough *string `json:"sendThrough"` // 用于发送数据的 IP 地址,当主机有多个 IP 地址时有效,默认值为 "0.0.0.0"。 Tag string `json:"tag"` Settings json.RawMessage `json:"settings"` // 视协议不同而不同。详见每个协议中的 OutboundConfigurationObject // "streamSettings":{"network":"%s","tlsSettings":{"disableSystemRoot":false},"wsSettings":{"path":""},"xtlsSettings":{"disableSystemRoot":false}} StreamSetting json.RawMessage `json:"streamSettings"` ProxySettings json.RawMessage `json:"proxySettings"` Mux json.RawMessage `json:"mux"` }
type V2rayRouteRule ¶
type V2rayRouteRule struct { DomainMatcher string `json:"domainMatcher"` Type string `json:"type"` Domains []string `json:"domains"` Ip []string `json:"ip"` InboundTag []string `json:"inboundTag"` OutboundTag string `json:"outboundTag"` //direct }
V2rayRouteRule https://www.v2fly.org/config/routing.html#ruleobject
type V2rayServer ¶
type V2rayServer struct {
// contains filtered or unexported fields
}
func NewV2ray ¶
func NewV2ray(v2rayPath string) *V2rayServer
func (V2rayServer) GetExeCmd ¶ added in v1.3.0
func (v V2rayServer) GetExeCmd() *exec.Cmd
func (V2rayServer) GetJsonConfig ¶ added in v1.3.0
func (v V2rayServer) GetJsonConfig() JsonConfig
func (V2rayServer) GetLocalPort ¶ added in v1.3.0
func (v V2rayServer) GetLocalPort() int
func (V2rayServer) GetV2rayConfigV4 ¶ added in v1.3.0
func (v V2rayServer) GetV2rayConfigV4() V2rayConfigV4
func (*V2rayServer) SetNode ¶
func (v *V2rayServer) SetNode(n V2rayNode) *V2rayServer
func (*V2rayServer) SetPort ¶
func (v *V2rayServer) SetPort(port int) *V2rayServer
func (*V2rayServer) Start ¶
func (v *V2rayServer) Start(configFile string) error
Start 启动v2ray进程。非代理池模式,会读取 routing.rules.json 文件。 routing.rules.json 的值会覆盖 v2ray.config.json 对应配置项的值