new: add warp option

This commit is contained in:
Hiddify
2024-01-25 18:37:08 +00:00
parent d86817d612
commit 6f167708a7
5 changed files with 196 additions and 8 deletions

View File

@@ -134,10 +134,36 @@ func patchOutbound(base option.Outbound, configOpt ConfigOptions) (*option.Outbo
if err != nil {
return nil, "", formatErr(err)
}
err = patchWarp(outbound)
if err != nil {
return nil, "", formatErr(err)
}
return &outbound, serverDomain, nil
}
func patchWarp(base option.Outbound) error {
if base.Type == C.TypeCustom {
if warp, ok := base.CustomOptions["warp"].(map[string]interface{}); ok {
key, _ := warp["key"].(string)
host, _ := warp["host"].(string)
port, _ := warp["port"].(float64)
fakePackets, _ := warp["fake_packets"].(string)
warpConfig, err := generateWarp(key, host, uint16(port))
if err != nil {
return err
}
base.Type = C.TypeWireGuard
base.WireGuardOptions = warpConfig.WireGuardOptions
base.WireGuardOptions.FakePackets = fakePackets
}
}
return nil
}
// func (o outboundMap) transportType() string {
// if transport, ok := o["transport"].(map[string]interface{}); ok {
// if transportType, ok := transport["type"].(string); ok {