runEngine opens the WinDivert backend, starts the bypass engine, and runs the pass-through TCP relay on profile.Listen. Requires Administrator + WinDivert.dll/WinDivert64.sys available (next to snix.exe or on PATH).
(ctx context.Context, out io.Writer, p *config.Profile)
| 27 | // the pass-through TCP relay on profile.Listen. Requires Administrator + |
| 28 | // WinDivert.dll/WinDivert64.sys available (next to snix.exe or on PATH). |
| 29 | func runEngine(ctx context.Context, out io.Writer, p *config.Profile) error { |
| 30 | remoteAddr, err := resolveIPv4(p.Connect.Host) |
| 31 | if err != nil { |
| 32 | return fmt.Errorf("resolve %s: %w", p.Connect.Host, err) |
| 33 | } |
| 34 | localIP, err := defaultIfaceIPv4(remoteAddr) |
| 35 | if err != nil { |
| 36 | return fmt.Errorf("local iface: %w", err) |
| 37 | } |
| 38 | sniPool := p.EffectiveSNIPool() |
| 39 | fmt.Fprintf(out, "snix: local=%s remote=%s:%d sni_pool=%v strategy=%s\n", |
| 40 | localIP, remoteAddr, p.Connect.Port, sniPool, p.Spoof.Strategy) |
| 41 | if p.Spoof.RandomizeTiming || p.Spoof.RandomizePadding || len(p.Spoof.StrategyRotation) > 0 { |
| 42 | fmt.Fprintf(out, "snix: randomization active timing=%v padding=%v rotation=%v id_delta_range=%d\n", |
| 43 | p.Spoof.RandomizeTiming, p.Spoof.RandomizePadding, |
| 44 | p.Spoof.StrategyRotation, p.Spoof.IPIDDeltaRange) |
| 45 | } |
| 46 | |
| 47 | scope := platform.Scope{ |
| 48 | LocalIP: localIP, |
| 49 | RemoteIP: remoteAddr, |
| 50 | RemotePort: p.Connect.Port, |
| 51 | } |
| 52 | |
| 53 | be := wbe.New(wbe.Config{}) |
| 54 | if err := be.Open(ctx, scope); err != nil { |
| 55 | return fmt.Errorf("WinDivert open: %w\n (run as Administrator; ensure WinDivert.dll and WinDivert64.sys are next to snix.exe)", err) |
| 56 | } |
| 57 | fmt.Fprintf(out, "snix: WinDivert filter installed\n") |
| 58 | defer func() { |
| 59 | if err := be.Close(); err != nil { |
| 60 | fmt.Fprintf(out, "snix: close: %v\n", err) |
| 61 | } else { |
| 62 | fmt.Fprintf(out, "snix: WinDivert filter removed\n") |
| 63 | } |
| 64 | }() |
| 65 | |
| 66 | eng, err := engine.New(engine.Config{ |
| 67 | Strategy: p.Spoof.Strategy, |
| 68 | SNIPool: sniPool, |
| 69 | Scope: scope, |
| 70 | Log: stdoutLogger{w: out}, |
| 71 | Knobs: fingerprint.Knobs{ |
| 72 | RandomizeTiming: p.Spoof.RandomizeTiming, |
| 73 | MinDelay: p.Spoof.MinDelay, |
| 74 | MaxDelay: p.Spoof.MaxDelay, |
| 75 | RandomizePadding: p.Spoof.RandomizePadding, |
| 76 | MinExtraPad: p.Spoof.MinExtraPad, |
| 77 | MaxExtraPad: p.Spoof.MaxExtraPad, |
| 78 | IPIDDeltaRange: p.Spoof.IPIDDeltaRange, |
| 79 | StrategyRotation: p.Spoof.StrategyRotation, |
| 80 | SNISelection: p.Spoof.SNISelection, |
| 81 | }, |
| 82 | }, be) |
| 83 | if err != nil { |
| 84 | return fmt.Errorf("engine: %w", err) |
| 85 | } |
| 86 | go eng.Run(ctx) |
nothing calls this directly
no test coverage detected