mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-09 07:09:54 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8562dcb19f |
@@ -57,6 +57,26 @@ func NewMetricsHandler(ctx context.Context, config *Config) (*MetricsHandler, er
|
|||||||
})
|
})
|
||||||
return resp
|
return resp
|
||||||
}))
|
}))
|
||||||
|
expvar.Publish("online", expvar.Func(func() interface{} {
|
||||||
|
resp := map[string]interface{}{}
|
||||||
|
c.statsManager.VisitOnlineMaps(func(name string, om feature_stats.OnlineMap) bool {
|
||||||
|
user := name
|
||||||
|
if parts := strings.Split(name, ">>>"); len(parts) >= 2 {
|
||||||
|
user = parts[1]
|
||||||
|
}
|
||||||
|
ips := map[string]int64{}
|
||||||
|
om.ForEach(func(ip string, lastSeen int64) bool {
|
||||||
|
ips[ip] = lastSeen
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
resp[user] = map[string]interface{}{
|
||||||
|
"count": om.Count(),
|
||||||
|
"ips": ips,
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return resp
|
||||||
|
}))
|
||||||
expvar.Publish("observatory", expvar.Func(func() interface{} {
|
expvar.Publish("observatory", expvar.Func(func() interface{} {
|
||||||
if c.observatory == nil {
|
if c.observatory == nil {
|
||||||
common.Must(core.RequireFeatures(ctx, func(observatory extension.Observatory) error {
|
common.Must(core.RequireFeatures(ctx, func(observatory extension.Observatory) error {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package tun
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/netip"
|
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
@@ -82,11 +80,6 @@ func (t *Handler) Init(ctx context.Context, pm policy.Manager, dispatcher routin
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return c.Control(func(fd uintptr) {
|
return c.Control(func(fd uintptr) {
|
||||||
addrPort, _ := netip.ParseAddrPort(address)
|
|
||||||
// skip loopback
|
|
||||||
if addrPort.Addr().IsLoopback() || strings.HasPrefix(strings.ToLower(address), "localhost:") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := setinterface(network, address, fd, iface)
|
err := setinterface(network, address, fd, iface)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogInfoInner(context.Background(), err, "[tun] falied to set interface")
|
errors.LogInfoInner(context.Background(), err, "[tun] falied to set interface")
|
||||||
|
|||||||
Reference in New Issue
Block a user