mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-18 17:12:47 +03:00
Compare commits
3 Commits
v1.13.12-e
...
extended
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cbc7691f0 | ||
|
|
d174962a04 | ||
|
|
9c80cf371c |
18
.github/build_openwrt_packages.sh
vendored
18
.github/build_openwrt_packages.sh
vendored
@@ -28,20 +28,24 @@ esac
|
|||||||
|
|
||||||
PKG_VERSION="${VERSION//-/\~}"
|
PKG_VERSION="${VERSION//-/\~}"
|
||||||
|
|
||||||
|
FPM_DIR=$(mktemp -d)
|
||||||
|
sed "s|release/|$PROJECT/release/|g;s|^LICENSE|$PROJECT/LICENSE|" "$PROJECT/.fpm_openwrt" > "$FPM_DIR/.fpm"
|
||||||
|
trap 'rm -rf "$FPM_DIR"' EXIT
|
||||||
|
|
||||||
for ARCH in $ARCHITECTURES; do
|
for ARCH in $ARCHITECTURES; do
|
||||||
cp "$PROJECT/.fpm_openwrt" "$PROJECT/.fpm"
|
TMP_DEB=$(mktemp -p "$DIST" _openwrt_XXXXXX.deb)
|
||||||
fpm -t deb \
|
rm -f "$TMP_DEB"
|
||||||
|
(cd "$FPM_DIR" && fpm -t deb \
|
||||||
-v "$PKG_VERSION" \
|
-v "$PKG_VERSION" \
|
||||||
-p "$DIST/_openwrt_tmp.deb" \
|
-p "$TMP_DEB" \
|
||||||
--architecture all \
|
--architecture all \
|
||||||
"$BINARY_PATH=/usr/bin/sing-box"
|
"$BINARY_PATH=/usr/bin/sing-box")
|
||||||
rm -f "$PROJECT/.fpm"
|
|
||||||
|
|
||||||
bash "$PROJECT/.github/deb2ipk.sh" \
|
bash "$PROJECT/.github/deb2ipk.sh" \
|
||||||
"$ARCH" \
|
"$ARCH" \
|
||||||
"$DIST/_openwrt_tmp.deb" \
|
"$TMP_DEB" \
|
||||||
"$DIST/sing-box-extended_${VERSION}_openwrt_${ARCH}.ipk"
|
"$DIST/sing-box-extended_${VERSION}_openwrt_${ARCH}.ipk"
|
||||||
rm -f "$DIST/_openwrt_tmp.deb"
|
rm -f "$TMP_DEB"
|
||||||
|
|
||||||
if command -v apk &>/dev/null; then
|
if command -v apk &>/dev/null; then
|
||||||
bash "$PROJECT/.github/build_openwrt_apk.sh" \
|
bash "$PROJECT/.github/build_openwrt_apk.sh" \
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
env:
|
env:
|
||||||
@@ -63,6 +64,7 @@ builds:
|
|||||||
- with_openvpn
|
- with_openvpn
|
||||||
- with_trusttunnel
|
- with_trusttunnel
|
||||||
- with_sudoku
|
- with_sudoku
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
targets:
|
targets:
|
||||||
@@ -123,6 +125,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
- with_naive_outbound
|
- with_naive_outbound
|
||||||
@@ -155,6 +158,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
- with_naive_outbound
|
- with_naive_outbound
|
||||||
@@ -187,6 +191,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
- with_naive_outbound
|
- with_naive_outbound
|
||||||
@@ -219,6 +224,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
- with_naive_outbound
|
- with_naive_outbound
|
||||||
@@ -251,6 +257,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
- with_naive_outbound
|
- with_naive_outbound
|
||||||
@@ -299,6 +306,7 @@ builds:
|
|||||||
- with_sudoku
|
- with_sudoku
|
||||||
- with_manager
|
- with_manager
|
||||||
- with_admin_panel
|
- with_admin_panel
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
- with_naive_outbound
|
- with_naive_outbound
|
||||||
@@ -353,6 +361,7 @@ builds:
|
|||||||
- with_openvpn
|
- with_openvpn
|
||||||
- with_trusttunnel
|
- with_trusttunnel
|
||||||
- with_sudoku
|
- with_sudoku
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
targets:
|
targets:
|
||||||
@@ -424,6 +433,7 @@ builds:
|
|||||||
- with_openvpn
|
- with_openvpn
|
||||||
- with_trusttunnel
|
- with_trusttunnel
|
||||||
- with_sudoku
|
- with_sudoku
|
||||||
|
- with_profiler
|
||||||
- badlinkname
|
- badlinkname
|
||||||
- tfogo_checklinkname0
|
- tfogo_checklinkname0
|
||||||
hooks:
|
hooks:
|
||||||
@@ -514,12 +524,6 @@ archives:
|
|||||||
- compressed-mips
|
- compressed-mips
|
||||||
- compressed-android
|
- compressed-android
|
||||||
name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if and .Mips (not (eq .Mips "hardfloat")) }}-{{ .Mips }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}-compressed'
|
name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if and .Mips (not (eq .Mips "hardfloat")) }}-{{ .Mips }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}-compressed'
|
||||||
- id: archive-openwrt
|
|
||||||
<<: *template
|
|
||||||
builds:
|
|
||||||
- openwrt
|
|
||||||
- openwrt-mips
|
|
||||||
name_template: '{{ .ProjectName }}-{{ .Version }}-openwrt-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if and .Mips (not (eq .Mips "hardfloat")) }}-{{ .Mips }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
|
|
||||||
source:
|
source:
|
||||||
enabled: false
|
enabled: false
|
||||||
name_template: '{{ .ProjectName }}-{{ .Version }}.source'
|
name_template: '{{ .ProjectName }}-{{ .Version }}.source'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](go.mod)
|
[](go.mod)
|
||||||
[](https://codeberg.org/shtorm-7/sing-box-extended)
|
[](https://codeberg.org/shtorm-7/sing-box-extended)
|
||||||
[](https://t.me/sing_box_extended)
|
[](https://t.me/sing_box_extended)
|
||||||
|
|
||||||
Sing-box with extended features.
|
Sing-box with extended features.
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package option
|
package option
|
||||||
|
|
||||||
import "github.com/sagernet/sing/common/json/badoption"
|
|
||||||
|
|
||||||
type ProfilerServiceOptions struct {
|
type ProfilerServiceOptions struct {
|
||||||
Listen string `json:"listen,omitempty"`
|
ListenOptions
|
||||||
ReadTimeout badoption.Duration `json:"read_timeout,omitempty"`
|
|
||||||
WriteTimeout badoption.Duration `json:"write_timeout,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,15 @@ import (
|
|||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
runtimePprof "runtime/pprof"
|
runtimePprof "runtime/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
boxService "github.com/sagernet/sing-box/adapter/service"
|
boxService "github.com/sagernet/sing-box/adapter/service"
|
||||||
|
"github.com/sagernet/sing-box/common/listener"
|
||||||
C "github.com/sagernet/sing-box/constant"
|
C "github.com/sagernet/sing-box/constant"
|
||||||
"github.com/sagernet/sing-box/log"
|
"github.com/sagernet/sing-box/log"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
N "github.com/sagernet/sing/common/network"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
)
|
)
|
||||||
@@ -24,23 +25,21 @@ func RegisterService(registry *boxService.Registry) {
|
|||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
boxService.Adapter
|
boxService.Adapter
|
||||||
logger log.ContextLogger
|
logger log.ContextLogger
|
||||||
listen string
|
listener *listener.Listener
|
||||||
readTimeout time.Duration
|
server *http.Server
|
||||||
writeTimeout time.Duration
|
|
||||||
server *http.Server
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(ctx context.Context, logger log.ContextLogger, tag string, options option.ProfilerServiceOptions) (adapter.Service, error) {
|
func NewService(ctx context.Context, logger log.ContextLogger, tag string, options option.ProfilerServiceOptions) (adapter.Service, error) {
|
||||||
if options.Listen == "" {
|
|
||||||
return nil, E.New("missing listen")
|
|
||||||
}
|
|
||||||
return &Service{
|
return &Service{
|
||||||
Adapter: boxService.NewAdapter(C.TypeProfiler, tag),
|
Adapter: boxService.NewAdapter(C.TypeProfiler, tag),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
listen: options.Listen,
|
listener: listener.New(listener.Options{
|
||||||
readTimeout: time.Duration(options.ReadTimeout),
|
Context: ctx,
|
||||||
writeTimeout: time.Duration(options.WriteTimeout),
|
Logger: logger,
|
||||||
|
Network: []string{N.NetworkTCP},
|
||||||
|
Listen: options.ListenOptions,
|
||||||
|
}),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,14 +68,15 @@ func (s *Service) Start(stage adapter.StartStage) error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
s.server = &http.Server{
|
s.server = &http.Server{
|
||||||
Addr: s.listen,
|
Handler: r,
|
||||||
Handler: r,
|
|
||||||
ReadTimeout: s.readTimeout,
|
|
||||||
WriteTimeout: s.writeTimeout,
|
|
||||||
}
|
}
|
||||||
s.logger.Info("profiler listening at ", s.listen)
|
tcpListener, err := s.listener.ListenTCP()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.logger.Info("profiler listening at ", tcpListener.Addr())
|
||||||
go func() {
|
go func() {
|
||||||
err := s.server.ListenAndServe()
|
err := s.server.Serve(tcpListener)
|
||||||
if err != nil && !E.IsClosed(err) {
|
if err != nil && !E.IsClosed(err) {
|
||||||
s.logger.Error(E.Cause(err, "serve profiler"))
|
s.logger.Error(E.Cause(err, "serve profiler"))
|
||||||
}
|
}
|
||||||
@@ -89,5 +89,5 @@ func (s *Service) Close() error {
|
|||||||
_ = s.server.Close()
|
_ = s.server.Close()
|
||||||
s.server = nil
|
s.server = nil
|
||||||
}
|
}
|
||||||
return nil
|
return s.listener.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user