Skip to content

Commit

Permalink
UPDATE v2ray_api AddInbound and WebUI
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhanqing committed Apr 13, 2024
1 parent 405a871 commit 35f3bd3
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 89 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ v2raypool.exe --getproxynodes
# 测速(测速基准使用https://www.google.com)。测速结束后,会自动选择最快的节点作为系统代理节点。
v2raypool.exe --testproxynodes
# 指定已测速过的域名,按速度从快到慢,查看代理节点信息
v2raypool.exe --getproxynodesbydomain=www.google.com
# 根据索引值激活某个节点为系统代理的端口(--getproxynodes 查看索引值,系统代理端口从VP_HTTP_PROXY的值读取)
v2raypool.exe --activeproxynode=16
Expand Down
33 changes: 24 additions & 9 deletions main/resource/add_v2ray_form.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
<div class="layui-form layui-form-pane" lay-filter="filter-test-layer" style="margin: 16px;">
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
<li class="layui-this">指定文件</li>
<li>指定节点</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">

<div class="layui-form-item">
<label class="layui-form-label">json配置文件</label>
<div class="layui-input-block">
<input type="text" name="config_file" placeholder="例: v2ray.config.json" value="" class="layui-input">
</div>
<div class="layui-form layui-form-pane" lay-filter="filter-test-layer" style="margin: 16px;">
<div class="layui-form-item">
<label class="layui-form-label">配置文件</label>
<div class="layui-input-block">
<input type="text" name="config_file" placeholder="例: v2ray.config.json" value="" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<button id="runv2ray" class="layui-btn" style="float: right;" lay-submit lay-filter="runv2ray">启动</button>
</div>
</div>

<div class="layui-form-item">
<button id="runv2ray" class="layui-btn" style="float: right;" lay-submit lay-filter="runv2ray">启动</button>
</div>

</div>
<div class="layui-tab-item">
指定节点
</div>

</div>
</div>

53 changes: 32 additions & 21 deletions main/resource/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ <h2 style="padding: 16px;text-align: center;">
V2rayPool控制面板
</h2>

<table class="layui-hide" id="nodeslist" lay-filter="nodeslist"></table>
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
<li class="layui-this">动态代理池</li>
<li>v2ray列表</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<table class="layui-hide" id="nodeslist" lay-filter="nodeslist"></table>
</div>
<div class="layui-tab-item">
<{% tplinclude "v2raylist.html" . | println %}>
</div>
</div>
</div>

</div>

Expand All @@ -54,13 +67,13 @@ <h2 style="padding: 16px;text-align: center;">
</div>

<div class="layui-col-xs8">
<i class="itable-top layui-icon" style="color:deeppink" lay-event="testNodes" id="testproxynodes"></i>
<!-- <button class="layui-btn layui-btn-sm" style="background-color: darkorange;" lay-event="testNodes" id="testproxynodes">测速</button> -->


<!-- <i class="itable-top layui-icon" style="color:deeppink" lay-event="testNodes" id="testproxynodes">⚡</i> -->
<!-- <i class="itable-top layui-icon layui-icon-play" style="color: green;" lay-event="startNodes" id="startproxynodes"></i> -->
<!-- <i class="itable-top layui-icon layui-icon-refresh-3" style="color: #1E9FFF;" lay-event="refreshData" id="refreshdata"></i> -->

<button class="layui-btn layui-btn-sm" lay-on="v2raylist">v2ray</button>
<!-- <button class="layui-btn layui-btn-sm" lay-on="v2raylist">v2ray</button> -->
<button class="layui-btn layui-btn-sm layui-bg-red" lay-event="testNodes" id="testproxynodes">测速</button>
<button class="layui-btn layui-btn-sm layui-bg-purple" lay-event="startNodes" id="startproxynodes">启动</button>
<button class="layui-btn layui-btn-sm" lay-on="subscribe">订阅</button>
<button class="layui-btn layui-btn-sm layui-bg-blue" lay-on="routingrules">路由规则</button>
Expand Down Expand Up @@ -134,17 +147,17 @@ <h2 style="padding: 16px;text-align: center;">
}
})
},
'v2raylist': () => {
layer.open({
title: 'v2ray服务状态',
type: 1,
area: ['80%', '80%'],
content: $('#v2raylistlayer'),
success: (layero, index, that) => {
table.reload('v2raylist')
}
})
},
// 'v2raylist': () => {
// layer.open({
// title: 'v2ray服务状态',
// type: 1,
// area: ['80%', '80%'],
// content: $('#v2raylistlayer'),
// success: (layero, index, that) => {
// table.reload('v2raylist')
// }
// })
// },
'subscribe': function () {
layer.open({
title: "更新订阅",
Expand Down Expand Up @@ -393,11 +406,9 @@ <h2 style="padding: 16px;text-align: center;">

</script>

<div id="settinglayer" style="display: none;">
<{% tplinclude "setting_form.html" . | println %}>
</div>

<{% tplinclude "v2raylist.html" . | println %}>
<div id="settinglayer" style="display: none;">
<{% tplinclude "setting_form.html" . | println %}>
</div>

<div id="addv2raylayer" style="display: none;">
<{% tplinclude "add_v2ray_form.html" nil | println %}>
Expand Down
3 changes: 2 additions & 1 deletion main/resource/v2raylist.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

<div id="v2raylistlayer" style="display: none;">
<!-- <div id="v2raylistlayer" style="display: none;"> -->
<div id="v2raylistlayer">
<table class="layui-hide" id="v2raylist" lay-filter="v2raylist"></table>
</div>

Expand Down
54 changes: 0 additions & 54 deletions proxy_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,60 +63,6 @@ func (p *ProxyNode) AddToPool(c *V2rayApiClient) error {
return err
}

// func (p *ProxyNode) Active(localPort int, c *V2rayApiClient) error {
// err := c.AddInbound(net.Port(localPort), TAG_OUTBOUND_ACTIVE, "http")
// if err != nil {
// return err
// }
// err = c.AddOutboundByV2rayNode(p.v2rayNode, TAG_OUTBOUND_ACTIVE)
// if err != nil {
// return err
// }
// p.status = 1
// return err
// }

// func (p *ProxyNode) UnActive(c *V2rayApiClient) error {
// err := c.RemoveOutbound(TAG_OUTBOUND_ACTIVE)
// if err != nil {
// return err
// }
// err = c.RemoveInbound(TAG_OUTBOUND_ACTIVE)
// if err != nil {
// return err
// }
// return err
// }

// func (p *ProxyNode) Start(path string) (err error) {
// v := NewV2ray(path, p.LocalPort)
// p.cmd, err = v.SetPort(p.LocalPort).SetNode(p.v2rayNode).Start()
// if p.cmd != nil {
// p.status = 1
// }
// fmt.Printf("\n---StartV2rayNode--i(%d)--Addr(%s)--Title(%s)--err(%v)---\n", p.Index, p.RemoteAddr, p.Title, err)
// return
// }

// func (p *ProxyNode) KillPidByLocalPort() (hasPid int, killResult error) {

// hasPid = miniutils.GetPidByPort(p.LocalPort)
// if hasPid > 0 {
// fmt.Printf("---proxyNode---KillPidByLocalPort(%d)---PID(%d)---\n", p.LocalPort, hasPid)
// killResult = miniutils.KillPid(fmt.Sprintf("%d", hasPid))
// return
// }
// return
// }

// func (p *ProxyNode) Stop() error {
// err := p.cmd.Process.Kill()
// if err == nil {
// p.status = 0
// }
// return err
// }

func (p *ProxyNode) Remove(c *V2rayApiClient, tag string) error {
if tag == "" {
tag = p.GetId()
Expand Down
12 changes: 9 additions & 3 deletions v2ray_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ func (a V2rayApiClient) AddInbound(inport net.Port, intag, protocol string) erro
protocol = strings.ToLower(protocol)
if protocol == "http" {
proxySet = &http.ServerConfig{
// AllowTransparent: true,
UserLevel: 0,
AllowTransparent: false,
Timeout: 30,
// UserLevel: 0,
}
}
if protocol == "socks" {
proxySet = &socks.ServerConfig{UserLevel: 0}
proxySet = &socks.ServerConfig{
AuthType: socks.AuthType_NO_AUTH,
UdpEnabled: true,
// Address: net.NewIPOrDomain(net.AnyIP),
// UserLevel: 0,
}
}

resp, err := a.c.AddInbound(a.ctx, &pros.AddInboundRequest{Inbound: &v5.InboundHandlerConfig{
Expand Down
3 changes: 2 additions & 1 deletion v2ray_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ func setV2rayConfigV4Inbounds(confv4 *V2rayConfigV4, inPort int, cf conf.Conf) {
protcl = "socks"
}
if protcl == "socks" {
inset1 = `{"auth":"noauth","ip":"127.0.0.1","udp":true}`
// inset1 = `{"auth":"noauth","ip":"127.0.0.1","udp":true}`
inset1 = `{"auth":"noauth","udp":true}`
}
inbd1 := V2rayInbound{
Protocol: protcl,
Expand Down

0 comments on commit 35f3bd3

Please sign in to comment.