mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-10 21:38:16 +03:00
Compare commits
2 Commits
v1.13.12-e
...
v1.13.12-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d174962a04 | ||
|
|
9c80cf371c |
18
.github/build_openwrt_packages.sh
vendored
18
.github/build_openwrt_packages.sh
vendored
@@ -28,20 +28,24 @@ esac
|
||||
|
||||
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
|
||||
cp "$PROJECT/.fpm_openwrt" "$PROJECT/.fpm"
|
||||
fpm -t deb \
|
||||
TMP_DEB=$(mktemp -p "$DIST" _openwrt_XXXXXX.deb)
|
||||
rm -f "$TMP_DEB"
|
||||
(cd "$FPM_DIR" && fpm -t deb \
|
||||
-v "$PKG_VERSION" \
|
||||
-p "$DIST/_openwrt_tmp.deb" \
|
||||
-p "$TMP_DEB" \
|
||||
--architecture all \
|
||||
"$BINARY_PATH=/usr/bin/sing-box"
|
||||
rm -f "$PROJECT/.fpm"
|
||||
"$BINARY_PATH=/usr/bin/sing-box")
|
||||
|
||||
bash "$PROJECT/.github/deb2ipk.sh" \
|
||||
"$ARCH" \
|
||||
"$DIST/_openwrt_tmp.deb" \
|
||||
"$TMP_DEB" \
|
||||
"$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
|
||||
bash "$PROJECT/.github/build_openwrt_apk.sh" \
|
||||
|
||||
@@ -28,6 +28,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
env:
|
||||
@@ -63,6 +64,7 @@ builds:
|
||||
- with_openvpn
|
||||
- with_trusttunnel
|
||||
- with_sudoku
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
targets:
|
||||
@@ -123,6 +125,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
- with_naive_outbound
|
||||
@@ -155,6 +158,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
- with_naive_outbound
|
||||
@@ -187,6 +191,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
- with_naive_outbound
|
||||
@@ -219,6 +224,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
- with_naive_outbound
|
||||
@@ -251,6 +257,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
- with_naive_outbound
|
||||
@@ -299,6 +306,7 @@ builds:
|
||||
- with_sudoku
|
||||
- with_manager
|
||||
- with_admin_panel
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
- with_naive_outbound
|
||||
@@ -353,6 +361,7 @@ builds:
|
||||
- with_openvpn
|
||||
- with_trusttunnel
|
||||
- with_sudoku
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
targets:
|
||||
@@ -424,6 +433,7 @@ builds:
|
||||
- with_openvpn
|
||||
- with_trusttunnel
|
||||
- with_sudoku
|
||||
- with_profiler
|
||||
- badlinkname
|
||||
- tfogo_checklinkname0
|
||||
hooks:
|
||||
@@ -514,12 +524,6 @@ archives:
|
||||
- compressed-mips
|
||||
- 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'
|
||||
- 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:
|
||||
enabled: false
|
||||
name_template: '{{ .ProjectName }}-{{ .Version }}.source'
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package option
|
||||
|
||||
import "github.com/sagernet/sing/common/json/badoption"
|
||||
|
||||
type ProfilerServiceOptions struct {
|
||||
Listen string `json:"listen,omitempty"`
|
||||
ReadTimeout badoption.Duration `json:"read_timeout,omitempty"`
|
||||
WriteTimeout badoption.Duration `json:"write_timeout,omitempty"`
|
||||
ListenOptions
|
||||
}
|
||||
|
||||
@@ -6,14 +6,15 @@ import (
|
||||
"net/http/pprof"
|
||||
runtimePprof "runtime/pprof"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
boxService "github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/common/listener"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
N "github.com/sagernet/sing/common/network"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
@@ -24,23 +25,21 @@ func RegisterService(registry *boxService.Registry) {
|
||||
|
||||
type Service struct {
|
||||
boxService.Adapter
|
||||
logger log.ContextLogger
|
||||
listen string
|
||||
readTimeout time.Duration
|
||||
writeTimeout time.Duration
|
||||
server *http.Server
|
||||
logger log.ContextLogger
|
||||
listener *listener.Listener
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
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{
|
||||
Adapter: boxService.NewAdapter(C.TypeProfiler, tag),
|
||||
logger: logger,
|
||||
listen: options.Listen,
|
||||
readTimeout: time.Duration(options.ReadTimeout),
|
||||
writeTimeout: time.Duration(options.WriteTimeout),
|
||||
Adapter: boxService.NewAdapter(C.TypeProfiler, tag),
|
||||
logger: logger,
|
||||
listener: listener.New(listener.Options{
|
||||
Context: ctx,
|
||||
Logger: logger,
|
||||
Network: []string{N.NetworkTCP},
|
||||
Listen: options.ListenOptions,
|
||||
}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -69,14 +68,15 @@ func (s *Service) Start(stage adapter.StartStage) error {
|
||||
})
|
||||
|
||||
s.server = &http.Server{
|
||||
Addr: s.listen,
|
||||
Handler: r,
|
||||
ReadTimeout: s.readTimeout,
|
||||
WriteTimeout: s.writeTimeout,
|
||||
Handler: r,
|
||||
}
|
||||
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() {
|
||||
err := s.server.ListenAndServe()
|
||||
err := s.server.Serve(tcpListener)
|
||||
if err != nil && !E.IsClosed(err) {
|
||||
s.logger.Error(E.Cause(err, "serve profiler"))
|
||||
}
|
||||
@@ -89,5 +89,5 @@ func (s *Service) Close() error {
|
||||
_ = s.server.Close()
|
||||
s.server = nil
|
||||
}
|
||||
return nil
|
||||
return s.listener.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user