修改脚本逻辑
This commit is contained in:
26
install.sh
26
install.sh
@@ -33,19 +33,6 @@ case $ARCH in
|
|||||||
*) echo -e "${RED}Unsupported architecture: $ARCH${NC}"; exit 1 ;;
|
*) echo -e "${RED}Unsupported architecture: $ARCH${NC}"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Interactive Prompts
|
|
||||||
read -p "Enter Panel URL (e.g., https://yourbase.com): " PANEL_URL
|
|
||||||
read -p "Enter Node ID: " NODE_ID
|
|
||||||
read -p "Enter Panel Token (Node Key): " PANEL_TOKEN
|
|
||||||
|
|
||||||
if [[ -z "$PANEL_URL" || -z "$NODE_ID" || -z "$PANEL_TOKEN" ]]; then
|
|
||||||
echo -e "${RED}All fields are required!${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clean up trailing slash
|
|
||||||
PANEL_URL="${PANEL_URL%/}"
|
|
||||||
|
|
||||||
# Prepare directories
|
# Prepare directories
|
||||||
mkdir -p "$CONFIG_DIR"
|
mkdir -p "$CONFIG_DIR"
|
||||||
mkdir -p "/var/lib/sing-box"
|
mkdir -p "/var/lib/sing-box"
|
||||||
@@ -126,6 +113,19 @@ build_sing_box() {
|
|||||||
install_go
|
install_go
|
||||||
build_sing_box
|
build_sing_box
|
||||||
|
|
||||||
|
# Interactive Prompts
|
||||||
|
read -p "Enter Panel URL (e.g., https://yourbase.com): " PANEL_URL
|
||||||
|
read -p "Enter Node ID: " NODE_ID
|
||||||
|
read -p "Enter Panel Token (Node Key): " PANEL_TOKEN
|
||||||
|
|
||||||
|
if [[ -z "$PANEL_URL" || -z "$NODE_ID" || -z "$PANEL_TOKEN" ]]; then
|
||||||
|
echo -e "${RED}All fields are required!${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up trailing slash
|
||||||
|
PANEL_URL="${PANEL_URL%/}"
|
||||||
|
|
||||||
# Generate Configuration
|
# Generate Configuration
|
||||||
echo -e "${YELLOW}Generating configuration...${NC}"
|
echo -e "${YELLOW}Generating configuration...${NC}"
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -16,7 +15,6 @@ import (
|
|||||||
"github.com/sagernet/sing-box/log"
|
"github.com/sagernet/sing-box/log"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
"github.com/sagernet/sing-box/service/ssmapi"
|
"github.com/sagernet/sing-box/service/ssmapi"
|
||||||
"github.com/sagernet/sing/common"
|
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
"github.com/sagernet/sing/service"
|
"github.com/sagernet/sing/service"
|
||||||
)
|
)
|
||||||
@@ -31,6 +29,7 @@ type Service struct {
|
|||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
logger log.ContextLogger
|
logger log.ContextLogger
|
||||||
options option.XBoardServiceOptions
|
options option.XBoardServiceOptions
|
||||||
|
httpClient *http.Client
|
||||||
traffics map[string]*ssmapi.TrafficManager
|
traffics map[string]*ssmapi.TrafficManager
|
||||||
users map[string]*ssmapi.UserManager
|
users map[string]*ssmapi.UserManager
|
||||||
servers map[string]adapter.ManagedSSMServer
|
servers map[string]adapter.ManagedSSMServer
|
||||||
@@ -67,7 +66,7 @@ func NewService(ctx context.Context, logger log.ContextLogger, tag string, optio
|
|||||||
}
|
}
|
||||||
|
|
||||||
inboundManager := service.FromContext[adapter.InboundManager](ctx)
|
inboundManager := service.FromContext[adapter.InboundManager](ctx)
|
||||||
allInbounds := inboundManager.List()
|
allInbounds := inboundManager.Inbounds()
|
||||||
for _, inbound := range allInbounds {
|
for _, inbound := range allInbounds {
|
||||||
managedServer, isManaged := inbound.(adapter.ManagedSSMServer)
|
managedServer, isManaged := inbound.(adapter.ManagedSSMServer)
|
||||||
if isManaged {
|
if isManaged {
|
||||||
|
|||||||
Reference in New Issue
Block a user