Added MakeFullPairingServer
This commit is contained in:
parent
8b56cb7bfa
commit
32dccf1359
|
@ -878,3 +878,39 @@ func GenerateImages(filepath string, aX, aY, bX, bY int) string {
|
|||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
// GetConnectionStringForBeingBootstrapped starts a server.Receiving server.PairingServer
|
||||
// then generates a server.ConnectionParams. Used when the device is Logged out or has no Account keys
|
||||
// and the device has no camera to read a QR code with
|
||||
//
|
||||
// Example: A desktop device (device without camera) receiving account data from mobile (device with camera)
|
||||
func GetConnectionStringForBeingBootstrapped() string {
|
||||
|
||||
}
|
||||
|
||||
// SetConnectionStringForBootstrappingAnotherDevice starts a server.Receiving server.PairingClient
|
||||
// Used when the devices is Logged in and therefore has Account keys and the has a camera to read a QR code
|
||||
//
|
||||
// Example: A mobile (device with camera) sending account data to a desktop device (device without camera)
|
||||
func SetConnectionStringForBootstrappingAnotherDevice(cs string) string {
|
||||
|
||||
}
|
||||
|
||||
// GetConnectionStringForBootstrappingAnotherDevice starts a server.Sending server.PairingServer
|
||||
// then generates a server.ConnectionParams. Used when the device is Logged in and therefore has Account keys
|
||||
// and the device might not have a camera
|
||||
//
|
||||
// Example: A mobile or desktop device (devices that MAY have a camera but MUST have a screen)
|
||||
// sending account data to a mobile (device with camera)
|
||||
func GetConnectionStringForBootstrappingAnotherDevice() string {
|
||||
|
||||
}
|
||||
|
||||
// InputQRCodeForBeingBootstrapped starts a server.Sending server.PairingClient
|
||||
// Used when the devices is Logged out or has no Account keys and has a camera to read a QR code
|
||||
//
|
||||
// Example: A mobile device (device with a camera) receiving account data from
|
||||
// a device with a screen (mobile or desktop devices)
|
||||
func InputQRCodeForBeingBootstrapped(cs string) string {
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ package server
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/status-im/status-go/multiaccounts"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
)
|
||||
|
@ -118,3 +121,47 @@ func (s *PairingServer) startSendingAccountData() error {
|
|||
})
|
||||
return s.Start()
|
||||
}
|
||||
|
||||
func MakeFullPairingServer(db *multiaccounts.Database, mode Mode, keystorePath, keyUID, password string) (*PairingServer, error) {
|
||||
tlsKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
AESKey := make([]byte, 32)
|
||||
_, err = rand.Read(AESKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
outboundIP, err := GetOutboundIP()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tlsCert, _, err := GenerateCertFromKey(tlsKey, time.Now(), outboundIP.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewPairingServer(&Config{
|
||||
// Things that can be generated
|
||||
PK: &tlsKey.PublicKey,
|
||||
EK: AESKey,
|
||||
Cert: &tlsCert,
|
||||
Hostname: outboundIP.String(),
|
||||
|
||||
// Things that can't be generated, but do come from the client
|
||||
Mode: mode,
|
||||
|
||||
PairingPayloadManagerConfig: &PairingPayloadManagerConfig{
|
||||
// Things that can't be generated, but can't come from client
|
||||
DB: db,
|
||||
|
||||
// Things that can't be generated, but do come from the client
|
||||
KeystorePath: keystorePath,
|
||||
KeyUID: keyUID,
|
||||
Password: password,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue