2022-11-22 09:05:54 +08:00
|
|
|
package wireguard
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/xtls/xray-core/common"
|
|
|
|
|
)
|
|
|
|
|
|
2023-11-18 11:27:17 +08:00
|
|
|
func init() {
|
|
|
|
|
common.Must(common.RegisterConfig((*DeviceConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
|
|
|
|
deviceConfig := config.(*DeviceConfig)
|
|
|
|
|
if deviceConfig.IsClient {
|
2026-06-16 23:24:39 +08:00
|
|
|
return NewClient(ctx, deviceConfig)
|
2023-11-18 11:27:17 +08:00
|
|
|
} else {
|
|
|
|
|
return NewServer(ctx, deviceConfig)
|
2022-11-22 09:05:54 +08:00
|
|
|
}
|
2023-11-18 11:27:17 +08:00
|
|
|
}))
|
2022-11-22 09:05:54 +08:00
|
|
|
}
|