Merge remote-tracking branch 'origin/dev_new' into dev_new

This commit is contained in:
Yuzuki616 2023-10-06 13:04:30 +08:00
commit 0cdb02f2f9
7 changed files with 56 additions and 60 deletions

View File

@ -142,11 +142,7 @@ jobs:
run: | run: |
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
cp ${GITHUB_WORKSPACE}/example/dns.json ./build_assets/dns.json cp ${GITHUB_WORKSPACE}/example/*.json ./build_assets/
cp ${GITHUB_WORKSPACE}/example/route.json ./build_assets/route.json
cp ${GITHUB_WORKSPACE}/example/custom_outbound.json ./build_assets/custom_outbound.json
cp ${GITHUB_WORKSPACE}/example/custom_inbound.json ./build_assets/custom_inbound.json
cp ${GITHUB_WORKSPACE}/example/config.yml.example ./build_assets/config.json
LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') LIST=('geoip geoip geoip' 'domain-list-community dlc geosite')
for i in "${LIST[@]}" for i in "${LIST[@]}"
do do

View File

@ -5,12 +5,12 @@
A V2board node server based on multi core, modified from XrayR. A V2board node server based on multi core, modified from XrayR.
一个基于多种内核的V2board节点服务端修改自XrayR支持V2ay,Trojan,Shadowsocks协议。 一个基于多种内核的V2board节点服务端修改自XrayR支持V2ay,Trojan,Shadowsocks协议。
**注意:1.1.0将更换为V2board1.7.0之后新增的Api原Api将被移除请1.7.0之前的用户使用1.1.0之前的版本。** **注意: 本项目需要V2board版本 >= 1.7.0**
## 特点 ## 特点
* 永久开源且免费。 * 永久开源且免费。
* 支持V2rayTrojan Shadowsocks多种协议。 * 支持Vmess/Vless, Trojan Shadowsocks, Hysteria多种协议。
* 支持Vless和XTLS等新特性。 * 支持Vless和XTLS等新特性。
* 支持单实例对接多节点,无需重复启动。 * 支持单实例对接多节点,无需重复启动。
* 支持限制在线IP。 * 支持限制在线IP。
@ -40,10 +40,7 @@ A V2board node server based on multi core, modified from XrayR.
- [ ] 重新实现动态限速 - [ ] 重新实现动态限速
- [ ] 重新实现在线IP同步跨节点在线IP限制 - [ ] 重新实现在线IP同步跨节点在线IP限制
- [x] 集成基本操作Command(Start, Stop, Restart, Status, Uninstall)
- [ ] 完善Hysteria内核支持
- [ ] 完善使用文档 - [ ] 完善使用文档
- [ ] 尽可能统一日志输出格式
## 软件安装 ## 软件安装

View File

@ -2,8 +2,6 @@ package panel
import ( import (
"fmt" "fmt"
log "github.com/sirupsen/logrus"
"github.com/goccy/go-json" "github.com/goccy/go-json"
) )
@ -67,6 +65,5 @@ func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error {
if err != nil { if err != nil {
return err return err
} }
log.Println(r.String())
return nil return nil
} }

View File

@ -1,7 +1,6 @@
package sing package sing
import ( import (
"context"
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
@ -215,8 +214,9 @@ func (b *Box) AddNode(tag string, info *panel.NodeInfo, config *conf.Options) er
if err != nil { if err != nil {
return err return err
} }
in, err := inbound.New( in, err := inbound.New(
context.Background(), b.ctx,
b.router, b.router,
b.logFactory.NewLogger(F.ToString("inbound/", c.Type, "[", tag, "]")), b.logFactory.NewLogger(F.ToString("inbound/", c.Type, "[", tag, "]")),
c, c,

View File

@ -3,14 +3,9 @@ package sing
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/goccy/go-json"
"io"
"os"
"runtime/debug"
"time"
"github.com/InazumaV/V2bX/conf" "github.com/InazumaV/V2bX/conf"
vCore "github.com/InazumaV/V2bX/core" vCore "github.com/InazumaV/V2bX/core"
"github.com/goccy/go-json"
"github.com/inazumav/sing-box/adapter" "github.com/inazumav/sing-box/adapter"
"github.com/inazumav/sing-box/inbound" "github.com/inazumav/sing-box/inbound"
"github.com/inazumav/sing-box/log" "github.com/inazumav/sing-box/log"
@ -22,6 +17,10 @@ import (
F "github.com/sagernet/sing/common/format" F "github.com/sagernet/sing/common/format"
"github.com/sagernet/sing/service" "github.com/sagernet/sing/service"
"github.com/sagernet/sing/service/pause" "github.com/sagernet/sing/service/pause"
"io"
"os"
"runtime/debug"
"time"
) )
var _ adapter.Service = (*Box)(nil) var _ adapter.Service = (*Box)(nil)
@ -32,6 +31,7 @@ type DNSConfig struct {
} }
type Box struct { type Box struct {
ctx context.Context
createdAt time.Time createdAt time.Time
router adapter.Router router adapter.Router
inbounds map[string]adapter.Inbound inbounds map[string]adapter.Inbound
@ -170,6 +170,7 @@ func New(c *conf.CoreConfig) (vCore.Core, error) {
} }
router.SetClashServer(server) router.SetClashServer(server)
return &Box{ return &Box{
ctx: ctx,
router: router, router: router,
inbounds: inMap, inbounds: inMap,
outbounds: outbounds, outbounds: outbounds,

View File

@ -164,12 +164,12 @@ func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network) (*
if user != nil && len(user.Email) > 0 { if user != nil && len(user.Email) > 0 {
limit, err = limiter.GetLimiter(sessionInbound.Tag) limit, err = limiter.GetLimiter(sessionInbound.Tag)
if err != nil { if err != nil {
newError("Get limit info error: ", err).AtError().WriteToLog() newError("get limiter ", sessionInbound.Tag, " error: ", err).AtError().WriteToLog()
common.Close(outboundLink.Writer) common.Close(outboundLink.Writer)
common.Close(inboundLink.Writer) common.Close(inboundLink.Writer)
common.Interrupt(outboundLink.Reader) common.Interrupt(outboundLink.Reader)
common.Interrupt(inboundLink.Reader) common.Interrupt(inboundLink.Reader)
return nil, nil, nil, newError("Get limit info error: ", err) return nil, nil, nil, newError("get limiter ", sessionInbound.Tag, " error: ", err)
} }
// Speed Limit and Device Limit // Speed Limit and Device Limit
w, reject := limit.CheckLimit(user.Email, w, reject := limit.CheckLimit(user.Email,
@ -414,25 +414,22 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
} }
sessionInbound := session.InboundFromContext(ctx) sessionInbound := session.InboundFromContext(ctx)
if sessionInbound.User != nil {
if l != nil { if l != nil {
// del connect count // del connect count
if sessionInbound.User != nil {
if destination.Network == net.Network_TCP { if destination.Network == net.Network_TCP {
defer func() { defer func() {
l.ConnLimiter.DelConnCount(sessionInbound.User.Email, sessionInbound.Source.Address.IP().String()) l.ConnLimiter.DelConnCount(sessionInbound.User.Email, sessionInbound.Source.Address.IP().String())
}() }()
} }
}
} else { } else {
var err error var err error
l, err = limiter.GetLimiter(sessionInbound.Tag) l, err = limiter.GetLimiter(sessionInbound.Tag)
if err != nil { if err != nil {
newError("get limiter error: ", err).AtError().WriteToLog(session.ExportIDToError(ctx)) newError("get limiter ", sessionInbound.Tag, " error: ", err).AtWarning().WriteToLog(session.ExportIDToError(ctx))
common.Close(link.Writer)
common.Interrupt(link.Reader)
return
} }
} }
if l != nil {
var destStr string var destStr string
if destination.Address.Family().IsDomain() { if destination.Address.Family().IsDomain() {
destStr = destination.Address.Domain() destStr = destination.Address.Domain()
@ -459,6 +456,8 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
return return
} }
} }
}
}
var handler outbound.Handler var handler outbound.Handler
@ -492,6 +491,10 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
} }
} }
if handler == nil {
handler = d.ohm.GetHandler(inTag)
}
if handler == nil { if handler == nil {
handler = d.ohm.GetDefaultHandler() handler = d.ohm.GetDefaultHandler()
} }

View File

@ -185,7 +185,9 @@
{ {
// xray // xray
"Name": "xray_node1",
"Core": "xray", "Core": "xray",
"CoreName": "",
"ApiHost": "http://127.0.0.1", "ApiHost": "http://127.0.0.1",
"ApiKey": "test", "ApiKey": "test",
"NodeID": 33, "NodeID": 33,