2024-03-10 19:45:03 +01:00
|
|
|
package v2
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2024-03-22 16:25:56 +00:00
|
|
|
"github.com/hiddify/hiddify-core/config"
|
|
|
|
|
pb "github.com/hiddify/hiddify-core/hiddifyrpc"
|
2024-03-10 19:45:03 +01:00
|
|
|
)
|
|
|
|
|
|
2024-03-16 01:39:33 +01:00
|
|
|
func (s *CoreService) GenerateWarpConfig(ctx context.Context, in *pb.GenerateWarpConfigRequest) (*pb.WarpGenerationResponse, error) {
|
|
|
|
|
return GenerateWarpConfig(in)
|
|
|
|
|
}
|
|
|
|
|
func GenerateWarpConfig(in *pb.GenerateWarpConfigRequest) (*pb.WarpGenerationResponse, error) {
|
2024-05-29 17:38:13 +02:00
|
|
|
identity, log, wg, err := config.GenerateWarpInfo(in.LicenseKey, in.AccountId, in.AccessToken)
|
2024-03-10 19:45:03 +01:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return &pb.WarpGenerationResponse{
|
|
|
|
|
Account: &pb.WarpAccount{
|
2024-05-29 17:38:13 +02:00
|
|
|
AccountId: identity.ID,
|
|
|
|
|
AccessToken: identity.Token,
|
2024-03-10 19:45:03 +01:00
|
|
|
},
|
|
|
|
|
Config: &pb.WarpWireguardConfig{
|
|
|
|
|
PrivateKey: wg.PrivateKey,
|
|
|
|
|
LocalAddressIpv4: wg.LocalAddressIPv4,
|
|
|
|
|
LocalAddressIpv6: wg.LocalAddressIPv6,
|
|
|
|
|
PeerPublicKey: wg.PeerPublicKey,
|
2024-05-31 13:08:55 +02:00
|
|
|
ClientId: wg.ClientID,
|
2024-03-10 19:45:03 +01:00
|
|
|
},
|
|
|
|
|
Log: log,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|