You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wormhole-server/pkg/transparent/transparent_windows.go

86 lines
2.6 KiB

//go:build windows
// +build windows
package transparent
import (
"context"
"fmt"
"net"
"github.com/sirupsen/logrus"
)
// Config Windows compatible configuration struct
type Config struct {
ProxyPort int // HTTP代理端口
TransparentPort int // 透明代理端口
DNSPort int // DNS代理端口
BypassIPs []string // 不代理的IP列表
BypassDomains []string // 不代理的域名列表
}
// TransparentProxy Windows implementation
type TransparentProxy struct {
config Config
logger *logrus.Logger
}
// NewTransparentProxy creates a new Windows transparent proxy (compatible interface)
func NewTransparentProxy(config Config, logger *logrus.Logger) *TransparentProxy {
return &TransparentProxy{
config: config,
logger: logger,
}
}
// SetupTransparentProxy sets up transparent proxy (Windows stub)
func (tp *TransparentProxy) SetupTransparentProxy(ctx context.Context) error {
tp.logger.Warn("Transparent proxy is not fully supported on Windows")
tp.logger.Info("Please use system proxy settings or HTTP proxy mode")
return fmt.Errorf("transparent proxy not supported on Windows")
}
// CleanupTransparentProxy cleans up transparent proxy (Windows stub)
func (tp *TransparentProxy) CleanupTransparentProxy() error {
tp.logger.Info("Transparent proxy cleanup (Windows)")
return nil
}
// GetOriginalDestination returns original destination (Windows stub)
func (tp *TransparentProxy) GetOriginalDestination(conn net.Conn) (string, error) {
return "", fmt.Errorf("transparent proxy not supported on Windows")
}
// RequiresRoot returns whether root privileges are required (Windows compatible)
func RequiresRoot() bool {
return false // Windows doesn't require root for this operation
}
// IsTransparentSupported checks if transparent proxy is supported (Windows compatible)
func IsTransparentSupported() bool {
return false // Windows implementation is not supported
}
// Start starts the transparent proxy (Windows implementation)
func (tp *TransparentProxy) Start(ctx context.Context) error {
return tp.SetupTransparentProxy(ctx)
}
// Stop stops the transparent proxy
func (tp *TransparentProxy) Stop() error {
return tp.CleanupTransparentProxy()
}
// SetupFirewallRules sets up firewall rules (Windows stub)
func (tp *TransparentProxy) SetupFirewallRules() error {
tp.logger.Warn("Firewall rule setup not implemented for Windows")
return nil
}
// CleanupFirewallRules cleans up firewall rules (Windows stub)
func (tp *TransparentProxy) CleanupFirewallRules() error {
tp.logger.Info("Firewall rule cleanup (Windows)")
return nil
}