add hpeer for non-node peers
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
9b07492180
commit
332378e3ff
20 changed files with 1348 additions and 195 deletions
7
Makefile
7
Makefile
|
@ -4,6 +4,7 @@ NAMESPACE?=stellarproject
|
||||||
IMAGE_NAMESPACE?=$(NAMESPACE)
|
IMAGE_NAMESPACE?=$(NAMESPACE)
|
||||||
APP=heimdall
|
APP=heimdall
|
||||||
CLI=hctl
|
CLI=hctl
|
||||||
|
PEER=hpeer
|
||||||
REPO?=$(NAMESPACE)/$(APP)
|
REPO?=$(NAMESPACE)/$(APP)
|
||||||
TAG?=dev
|
TAG?=dev
|
||||||
BUILD?=-dev
|
BUILD?=-dev
|
||||||
|
@ -53,7 +54,7 @@ generate:
|
||||||
bindir:
|
bindir:
|
||||||
@mkdir -p bin
|
@mkdir -p bin
|
||||||
|
|
||||||
binaries: cli daemon
|
binaries: cli daemon peer
|
||||||
|
|
||||||
cli: bindir
|
cli: bindir
|
||||||
@>&2 echo " -> building cli ${COMMIT}${BUILD}"
|
@>&2 echo " -> building cli ${COMMIT}${BUILD}"
|
||||||
|
@ -63,6 +64,10 @@ daemon: bindir
|
||||||
@>&2 echo " -> building daemon ${COMMIT}${BUILD}"
|
@>&2 echo " -> building daemon ${COMMIT}${BUILD}"
|
||||||
@cd cmd/$(APP) && CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -installsuffix cgo -ldflags "-w -X github.com/$(REPO)/version.GitCommit=$(COMMIT) -X github.com/$(REPO)/version.Build=$(BUILD)" -o ../../bin/$(APP)$(BINARY_SUFFIX) .
|
@cd cmd/$(APP) && CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -installsuffix cgo -ldflags "-w -X github.com/$(REPO)/version.GitCommit=$(COMMIT) -X github.com/$(REPO)/version.Build=$(BUILD)" -o ../../bin/$(APP)$(BINARY_SUFFIX) .
|
||||||
|
|
||||||
|
peer: bindir
|
||||||
|
@>&2 echo " -> building peer ${COMMIT}${BUILD}"
|
||||||
|
@cd cmd/$(PEER) && CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -installsuffix cgo -ldflags "-w -X github.com/$(REPO)/version.GitCommit=$(COMMIT) -X github.com/$(REPO)/version.Build=$(BUILD)" -o ../../bin/$(PEER)$(BINARY_SUFFIX) .
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@echo " -> $@"
|
@echo " -> $@"
|
||||||
@test -z "$$(go vet ${PACKAGES} 2>&1 | tee /dev/stderr)"
|
@test -z "$$(go vet ${PACKAGES} 2>&1 | tee /dev/stderr)"
|
||||||
|
|
|
@ -82,7 +82,7 @@ func (m *Master) GetRedisURL() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConnectRequest struct {
|
type JoinRequest struct {
|
||||||
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
ClusterKey string `protobuf:"bytes,2,opt,name=cluster_key,json=clusterKey,proto3" json:"cluster_key,omitempty"`
|
ClusterKey string `protobuf:"bytes,2,opt,name=cluster_key,json=clusterKey,proto3" json:"cluster_key,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
@ -90,11 +90,94 @@ type ConnectRequest struct {
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *JoinRequest) Reset() { *m = JoinRequest{} }
|
||||||
|
func (m *JoinRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*JoinRequest) ProtoMessage() {}
|
||||||
|
func (*JoinRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b6184fc395da86b1, []int{1}
|
||||||
|
}
|
||||||
|
func (m *JoinRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_JoinRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *JoinRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_JoinRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *JoinRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_JoinRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *JoinRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_JoinRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *JoinRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_JoinRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_JoinRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *JoinRequest) GetID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *JoinRequest) GetClusterKey() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ClusterKey
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type JoinResponse struct {
|
||||||
|
Master *Master `protobuf:"bytes,1,opt,name=master,proto3" json:"master,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *JoinResponse) Reset() { *m = JoinResponse{} }
|
||||||
|
func (m *JoinResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*JoinResponse) ProtoMessage() {}
|
||||||
|
func (*JoinResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b6184fc395da86b1, []int{2}
|
||||||
|
}
|
||||||
|
func (m *JoinResponse) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_JoinResponse.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *JoinResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_JoinResponse.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *JoinResponse) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_JoinResponse.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *JoinResponse) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_JoinResponse.Size(m)
|
||||||
|
}
|
||||||
|
func (m *JoinResponse) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_JoinResponse.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_JoinResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *JoinResponse) GetMaster() *Master {
|
||||||
|
if m != nil {
|
||||||
|
return m.Master
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConnectRequest struct {
|
||||||
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ConnectRequest) Reset() { *m = ConnectRequest{} }
|
func (m *ConnectRequest) Reset() { *m = ConnectRequest{} }
|
||||||
func (m *ConnectRequest) String() string { return proto.CompactTextString(m) }
|
func (m *ConnectRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ConnectRequest) ProtoMessage() {}
|
func (*ConnectRequest) ProtoMessage() {}
|
||||||
func (*ConnectRequest) Descriptor() ([]byte, []int) {
|
func (*ConnectRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{1}
|
return fileDescriptor_b6184fc395da86b1, []int{3}
|
||||||
}
|
}
|
||||||
func (m *ConnectRequest) XXX_Unmarshal(b []byte) error {
|
func (m *ConnectRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_ConnectRequest.Unmarshal(m, b)
|
return xxx_messageInfo_ConnectRequest.Unmarshal(m, b)
|
||||||
|
@ -121,15 +204,11 @@ func (m *ConnectRequest) GetID() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ConnectRequest) GetClusterKey() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.ClusterKey
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConnectResponse struct {
|
type ConnectResponse struct {
|
||||||
Master *Master `protobuf:"bytes,1,opt,name=master,proto3" json:"master,omitempty"`
|
KeyPair *KeyPair `protobuf:"bytes,1,opt,name=keypair,proto3" json:"keypair,omitempty"`
|
||||||
|
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||||
|
Peers []*Peer `protobuf:"bytes,3,rep,name=peers,proto3" json:"peers,omitempty"`
|
||||||
|
DNS []string `protobuf:"bytes,4,rep,name=dns,proto3" json:"dns,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
@ -139,7 +218,7 @@ func (m *ConnectResponse) Reset() { *m = ConnectResponse{} }
|
||||||
func (m *ConnectResponse) String() string { return proto.CompactTextString(m) }
|
func (m *ConnectResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ConnectResponse) ProtoMessage() {}
|
func (*ConnectResponse) ProtoMessage() {}
|
||||||
func (*ConnectResponse) Descriptor() ([]byte, []int) {
|
func (*ConnectResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{2}
|
return fileDescriptor_b6184fc395da86b1, []int{4}
|
||||||
}
|
}
|
||||||
func (m *ConnectResponse) XXX_Unmarshal(b []byte) error {
|
func (m *ConnectResponse) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_ConnectResponse.Unmarshal(m, b)
|
return xxx_messageInfo_ConnectResponse.Unmarshal(m, b)
|
||||||
|
@ -159,9 +238,174 @@ func (m *ConnectResponse) XXX_DiscardUnknown() {
|
||||||
|
|
||||||
var xxx_messageInfo_ConnectResponse proto.InternalMessageInfo
|
var xxx_messageInfo_ConnectResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *ConnectResponse) GetMaster() *Master {
|
func (m *ConnectResponse) GetKeyPair() *KeyPair {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Master
|
return m.KeyPair
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ConnectResponse) GetAddress() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Address
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ConnectResponse) GetPeers() []*Peer {
|
||||||
|
if m != nil {
|
||||||
|
return m.Peers
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ConnectResponse) GetDNS() []string {
|
||||||
|
if m != nil {
|
||||||
|
return m.DNS
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthorizePeerRequest struct {
|
||||||
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AuthorizePeerRequest) Reset() { *m = AuthorizePeerRequest{} }
|
||||||
|
func (m *AuthorizePeerRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*AuthorizePeerRequest) ProtoMessage() {}
|
||||||
|
func (*AuthorizePeerRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b6184fc395da86b1, []int{5}
|
||||||
|
}
|
||||||
|
func (m *AuthorizePeerRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_AuthorizePeerRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *AuthorizePeerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_AuthorizePeerRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *AuthorizePeerRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_AuthorizePeerRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *AuthorizePeerRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_AuthorizePeerRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *AuthorizePeerRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_AuthorizePeerRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_AuthorizePeerRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *AuthorizePeerRequest) GetID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeauthorizePeerRequest struct {
|
||||||
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DeauthorizePeerRequest) Reset() { *m = DeauthorizePeerRequest{} }
|
||||||
|
func (m *DeauthorizePeerRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*DeauthorizePeerRequest) ProtoMessage() {}
|
||||||
|
func (*DeauthorizePeerRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b6184fc395da86b1, []int{6}
|
||||||
|
}
|
||||||
|
func (m *DeauthorizePeerRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_DeauthorizePeerRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *DeauthorizePeerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_DeauthorizePeerRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *DeauthorizePeerRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_DeauthorizePeerRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *DeauthorizePeerRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_DeauthorizePeerRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *DeauthorizePeerRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_DeauthorizePeerRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_DeauthorizePeerRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *DeauthorizePeerRequest) GetID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthorizedPeersRequest struct {
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AuthorizedPeersRequest) Reset() { *m = AuthorizedPeersRequest{} }
|
||||||
|
func (m *AuthorizedPeersRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*AuthorizedPeersRequest) ProtoMessage() {}
|
||||||
|
func (*AuthorizedPeersRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b6184fc395da86b1, []int{7}
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_AuthorizedPeersRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_AuthorizedPeersRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_AuthorizedPeersRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_AuthorizedPeersRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_AuthorizedPeersRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_AuthorizedPeersRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
type AuthorizedPeersResponse struct {
|
||||||
|
IDs []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AuthorizedPeersResponse) Reset() { *m = AuthorizedPeersResponse{} }
|
||||||
|
func (m *AuthorizedPeersResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*AuthorizedPeersResponse) ProtoMessage() {}
|
||||||
|
func (*AuthorizedPeersResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b6184fc395da86b1, []int{8}
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersResponse) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_AuthorizedPeersResponse.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_AuthorizedPeersResponse.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersResponse) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_AuthorizedPeersResponse.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersResponse) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_AuthorizedPeersResponse.Size(m)
|
||||||
|
}
|
||||||
|
func (m *AuthorizedPeersResponse) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_AuthorizedPeersResponse.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_AuthorizedPeersResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *AuthorizedPeersResponse) GetIDs() []string {
|
||||||
|
if m != nil {
|
||||||
|
return m.IDs
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -178,7 +422,7 @@ func (m *KeyPair) Reset() { *m = KeyPair{} }
|
||||||
func (m *KeyPair) String() string { return proto.CompactTextString(m) }
|
func (m *KeyPair) String() string { return proto.CompactTextString(m) }
|
||||||
func (*KeyPair) ProtoMessage() {}
|
func (*KeyPair) ProtoMessage() {}
|
||||||
func (*KeyPair) Descriptor() ([]byte, []int) {
|
func (*KeyPair) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{3}
|
return fileDescriptor_b6184fc395da86b1, []int{9}
|
||||||
}
|
}
|
||||||
func (m *KeyPair) XXX_Unmarshal(b []byte) error {
|
func (m *KeyPair) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_KeyPair.Unmarshal(m, b)
|
return xxx_messageInfo_KeyPair.Unmarshal(m, b)
|
||||||
|
@ -229,7 +473,7 @@ func (m *Node) Reset() { *m = Node{} }
|
||||||
func (m *Node) String() string { return proto.CompactTextString(m) }
|
func (m *Node) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Node) ProtoMessage() {}
|
func (*Node) ProtoMessage() {}
|
||||||
func (*Node) Descriptor() ([]byte, []int) {
|
func (*Node) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{4}
|
return fileDescriptor_b6184fc395da86b1, []int{10}
|
||||||
}
|
}
|
||||||
func (m *Node) XXX_Unmarshal(b []byte) error {
|
func (m *Node) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_Node.Unmarshal(m, b)
|
return xxx_messageInfo_Node.Unmarshal(m, b)
|
||||||
|
@ -308,7 +552,7 @@ func (m *NodesRequest) Reset() { *m = NodesRequest{} }
|
||||||
func (m *NodesRequest) String() string { return proto.CompactTextString(m) }
|
func (m *NodesRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*NodesRequest) ProtoMessage() {}
|
func (*NodesRequest) ProtoMessage() {}
|
||||||
func (*NodesRequest) Descriptor() ([]byte, []int) {
|
func (*NodesRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{5}
|
return fileDescriptor_b6184fc395da86b1, []int{11}
|
||||||
}
|
}
|
||||||
func (m *NodesRequest) XXX_Unmarshal(b []byte) error {
|
func (m *NodesRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_NodesRequest.Unmarshal(m, b)
|
return xxx_messageInfo_NodesRequest.Unmarshal(m, b)
|
||||||
|
@ -339,7 +583,7 @@ func (m *NodesResponse) Reset() { *m = NodesResponse{} }
|
||||||
func (m *NodesResponse) String() string { return proto.CompactTextString(m) }
|
func (m *NodesResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*NodesResponse) ProtoMessage() {}
|
func (*NodesResponse) ProtoMessage() {}
|
||||||
func (*NodesResponse) Descriptor() ([]byte, []int) {
|
func (*NodesResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{6}
|
return fileDescriptor_b6184fc395da86b1, []int{12}
|
||||||
}
|
}
|
||||||
func (m *NodesResponse) XXX_Unmarshal(b []byte) error {
|
func (m *NodesResponse) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_NodesResponse.Unmarshal(m, b)
|
return xxx_messageInfo_NodesResponse.Unmarshal(m, b)
|
||||||
|
@ -380,7 +624,7 @@ func (m *Peer) Reset() { *m = Peer{} }
|
||||||
func (m *Peer) String() string { return proto.CompactTextString(m) }
|
func (m *Peer) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Peer) ProtoMessage() {}
|
func (*Peer) ProtoMessage() {}
|
||||||
func (*Peer) Descriptor() ([]byte, []int) {
|
func (*Peer) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{7}
|
return fileDescriptor_b6184fc395da86b1, []int{13}
|
||||||
}
|
}
|
||||||
func (m *Peer) XXX_Unmarshal(b []byte) error {
|
func (m *Peer) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_Peer.Unmarshal(m, b)
|
return xxx_messageInfo_Peer.Unmarshal(m, b)
|
||||||
|
@ -438,7 +682,7 @@ func (m *PeersRequest) Reset() { *m = PeersRequest{} }
|
||||||
func (m *PeersRequest) String() string { return proto.CompactTextString(m) }
|
func (m *PeersRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*PeersRequest) ProtoMessage() {}
|
func (*PeersRequest) ProtoMessage() {}
|
||||||
func (*PeersRequest) Descriptor() ([]byte, []int) {
|
func (*PeersRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{8}
|
return fileDescriptor_b6184fc395da86b1, []int{14}
|
||||||
}
|
}
|
||||||
func (m *PeersRequest) XXX_Unmarshal(b []byte) error {
|
func (m *PeersRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_PeersRequest.Unmarshal(m, b)
|
return xxx_messageInfo_PeersRequest.Unmarshal(m, b)
|
||||||
|
@ -469,7 +713,7 @@ func (m *PeersResponse) Reset() { *m = PeersResponse{} }
|
||||||
func (m *PeersResponse) String() string { return proto.CompactTextString(m) }
|
func (m *PeersResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*PeersResponse) ProtoMessage() {}
|
func (*PeersResponse) ProtoMessage() {}
|
||||||
func (*PeersResponse) Descriptor() ([]byte, []int) {
|
func (*PeersResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{9}
|
return fileDescriptor_b6184fc395da86b1, []int{15}
|
||||||
}
|
}
|
||||||
func (m *PeersResponse) XXX_Unmarshal(b []byte) error {
|
func (m *PeersResponse) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_PeersResponse.Unmarshal(m, b)
|
return xxx_messageInfo_PeersResponse.Unmarshal(m, b)
|
||||||
|
@ -508,7 +752,7 @@ func (m *Route) Reset() { *m = Route{} }
|
||||||
func (m *Route) String() string { return proto.CompactTextString(m) }
|
func (m *Route) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Route) ProtoMessage() {}
|
func (*Route) ProtoMessage() {}
|
||||||
func (*Route) Descriptor() ([]byte, []int) {
|
func (*Route) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{10}
|
return fileDescriptor_b6184fc395da86b1, []int{16}
|
||||||
}
|
}
|
||||||
func (m *Route) XXX_Unmarshal(b []byte) error {
|
func (m *Route) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_Route.Unmarshal(m, b)
|
return xxx_messageInfo_Route.Unmarshal(m, b)
|
||||||
|
@ -554,7 +798,7 @@ func (m *CreateRouteRequest) Reset() { *m = CreateRouteRequest{} }
|
||||||
func (m *CreateRouteRequest) String() string { return proto.CompactTextString(m) }
|
func (m *CreateRouteRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CreateRouteRequest) ProtoMessage() {}
|
func (*CreateRouteRequest) ProtoMessage() {}
|
||||||
func (*CreateRouteRequest) Descriptor() ([]byte, []int) {
|
func (*CreateRouteRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{11}
|
return fileDescriptor_b6184fc395da86b1, []int{17}
|
||||||
}
|
}
|
||||||
func (m *CreateRouteRequest) XXX_Unmarshal(b []byte) error {
|
func (m *CreateRouteRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_CreateRouteRequest.Unmarshal(m, b)
|
return xxx_messageInfo_CreateRouteRequest.Unmarshal(m, b)
|
||||||
|
@ -599,7 +843,7 @@ func (m *DeleteRouteRequest) Reset() { *m = DeleteRouteRequest{} }
|
||||||
func (m *DeleteRouteRequest) String() string { return proto.CompactTextString(m) }
|
func (m *DeleteRouteRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DeleteRouteRequest) ProtoMessage() {}
|
func (*DeleteRouteRequest) ProtoMessage() {}
|
||||||
func (*DeleteRouteRequest) Descriptor() ([]byte, []int) {
|
func (*DeleteRouteRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{12}
|
return fileDescriptor_b6184fc395da86b1, []int{18}
|
||||||
}
|
}
|
||||||
func (m *DeleteRouteRequest) XXX_Unmarshal(b []byte) error {
|
func (m *DeleteRouteRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_DeleteRouteRequest.Unmarshal(m, b)
|
return xxx_messageInfo_DeleteRouteRequest.Unmarshal(m, b)
|
||||||
|
@ -636,7 +880,7 @@ func (m *RoutesRequest) Reset() { *m = RoutesRequest{} }
|
||||||
func (m *RoutesRequest) String() string { return proto.CompactTextString(m) }
|
func (m *RoutesRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*RoutesRequest) ProtoMessage() {}
|
func (*RoutesRequest) ProtoMessage() {}
|
||||||
func (*RoutesRequest) Descriptor() ([]byte, []int) {
|
func (*RoutesRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{13}
|
return fileDescriptor_b6184fc395da86b1, []int{19}
|
||||||
}
|
}
|
||||||
func (m *RoutesRequest) XXX_Unmarshal(b []byte) error {
|
func (m *RoutesRequest) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_RoutesRequest.Unmarshal(m, b)
|
return xxx_messageInfo_RoutesRequest.Unmarshal(m, b)
|
||||||
|
@ -667,7 +911,7 @@ func (m *RoutesResponse) Reset() { *m = RoutesResponse{} }
|
||||||
func (m *RoutesResponse) String() string { return proto.CompactTextString(m) }
|
func (m *RoutesResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*RoutesResponse) ProtoMessage() {}
|
func (*RoutesResponse) ProtoMessage() {}
|
||||||
func (*RoutesResponse) Descriptor() ([]byte, []int) {
|
func (*RoutesResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b6184fc395da86b1, []int{14}
|
return fileDescriptor_b6184fc395da86b1, []int{20}
|
||||||
}
|
}
|
||||||
func (m *RoutesResponse) XXX_Unmarshal(b []byte) error {
|
func (m *RoutesResponse) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_RoutesResponse.Unmarshal(m, b)
|
return xxx_messageInfo_RoutesResponse.Unmarshal(m, b)
|
||||||
|
@ -696,8 +940,14 @@ func (m *RoutesResponse) GetRoutes() []*Route {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Master)(nil), "io.stellarproject.heimdall.api.v1.Master")
|
proto.RegisterType((*Master)(nil), "io.stellarproject.heimdall.api.v1.Master")
|
||||||
|
proto.RegisterType((*JoinRequest)(nil), "io.stellarproject.heimdall.api.v1.JoinRequest")
|
||||||
|
proto.RegisterType((*JoinResponse)(nil), "io.stellarproject.heimdall.api.v1.JoinResponse")
|
||||||
proto.RegisterType((*ConnectRequest)(nil), "io.stellarproject.heimdall.api.v1.ConnectRequest")
|
proto.RegisterType((*ConnectRequest)(nil), "io.stellarproject.heimdall.api.v1.ConnectRequest")
|
||||||
proto.RegisterType((*ConnectResponse)(nil), "io.stellarproject.heimdall.api.v1.ConnectResponse")
|
proto.RegisterType((*ConnectResponse)(nil), "io.stellarproject.heimdall.api.v1.ConnectResponse")
|
||||||
|
proto.RegisterType((*AuthorizePeerRequest)(nil), "io.stellarproject.heimdall.api.v1.AuthorizePeerRequest")
|
||||||
|
proto.RegisterType((*DeauthorizePeerRequest)(nil), "io.stellarproject.heimdall.api.v1.DeauthorizePeerRequest")
|
||||||
|
proto.RegisterType((*AuthorizedPeersRequest)(nil), "io.stellarproject.heimdall.api.v1.AuthorizedPeersRequest")
|
||||||
|
proto.RegisterType((*AuthorizedPeersResponse)(nil), "io.stellarproject.heimdall.api.v1.AuthorizedPeersResponse")
|
||||||
proto.RegisterType((*KeyPair)(nil), "io.stellarproject.heimdall.api.v1.KeyPair")
|
proto.RegisterType((*KeyPair)(nil), "io.stellarproject.heimdall.api.v1.KeyPair")
|
||||||
proto.RegisterType((*Node)(nil), "io.stellarproject.heimdall.api.v1.Node")
|
proto.RegisterType((*Node)(nil), "io.stellarproject.heimdall.api.v1.Node")
|
||||||
proto.RegisterType((*NodesRequest)(nil), "io.stellarproject.heimdall.api.v1.NodesRequest")
|
proto.RegisterType((*NodesRequest)(nil), "io.stellarproject.heimdall.api.v1.NodesRequest")
|
||||||
|
@ -717,59 +967,71 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_b6184fc395da86b1 = []byte{
|
var fileDescriptor_b6184fc395da86b1 = []byte{
|
||||||
// 831 bytes of a gzipped FileDescriptorProto
|
// 1014 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08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 0x5d, 0xe6, 0xcc, 0x79, 0xce, 0x39, 0x7e, 0xce, 0x73, 0x8e, 0x1d,
|
||||||
0x26, 0x9f, 0x06, 0x33, 0xb6, 0x08, 0x33, 0x49, 0xd2, 0x34, 0x16, 0x5c, 0xb0, 0x2b, 0x32, 0x93,
|
0xf8, 0x78, 0x12, 0xf0, 0xd3, 0xf9, 0x89, 0x3d, 0xa6, 0x53, 0x27, 0xe6, 0x24, 0x0c, 0xbd, 0x88,
|
||||||
0xe1, 0x1b, 0x42, 0x17, 0x49, 0x9c, 0xa6, 0x61, 0xcc, 0x69, 0xb8, 0x1a, 0xd6, 0x71, 0xc0, 0x05,
|
0x45, 0xf4, 0x8c, 0x8c, 0xb9, 0x73, 0x4a, 0x82, 0xa9, 0xef, 0x85, 0xa1, 0xe3, 0xb1, 0xc0, 0xb9,
|
||||||
0x93, 0x0c, 0x7d, 0x40, 0x59, 0xb0, 0x8b, 0x08, 0xea, 0x8a, 0x98, 0xd3, 0x60, 0x35, 0x1c, 0xbc,
|
0xe8, 0x66, 0x67, 0x9b, 0x45, 0x94, 0x53, 0xf4, 0x4e, 0x40, 0xed, 0x4d, 0x84, 0x9d, 0x79, 0x78,
|
||||||
0x3b, 0x67, 0x73, 0xa6, 0xab, 0x43, 0xf5, 0x55, 0x02, 0x07, 0xef, 0xcd, 0x19, 0x9b, 0xa7, 0x24,
|
0x2c, 0xb0, 0x2f, 0xba, 0xed, 0x7b, 0x13, 0x3a, 0xa1, 0xd2, 0xdb, 0x11, 0xbf, 0x12, 0x60, 0xfb,
|
||||||
0xd4, 0xd1, 0x34, 0xff, 0x29, 0x24, 0x0b, 0x2e, 0xd7, 0x66, 0xd1, 0xbb, 0xbd, 0x28, 0xe9, 0x82,
|
0xad, 0x09, 0xa5, 0x93, 0x90, 0x38, 0xf2, 0x74, 0x32, 0xff, 0xc1, 0x21, 0x53, 0xc6, 0x17, 0xea,
|
||||||
0x64, 0x32, 0x5e, 0xf0, 0xb2, 0xc0, 0xff,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0b, 0xe3, 0x4b, 0xfc, 0x35, 0xae, 0xc9, 0xeb, 0x97,
|
||||||
0x25, 0x99, 0x49, 0x4c, 0x7e, 0xce, 0x49, 0x26, 0xef, 0x15, 0xe2, 0x81, 0x33, 0x4b, 0x73, 0xa5,
|
0x51, 0x68, 0x3d, 0x05, 0xfd, 0x2b, 0x1a, 0xcc, 0x30, 0xf9, 0x71, 0x4e, 0x62, 0xbe, 0xb5, 0x0a,
|
||||||
0x75, 0x72, 0x4d, 0xd6, 0xa5, 0x0e, 0x0c, 0x26, 0x75, 0x49, 0xd6, 0xfe, 0x2b, 0x38, 0xaa, 0xa9,
|
0x13, 0xf4, 0x71, 0x38, 0x17, 0x85, 0x8e, 0xce, 0xc9, 0x22, 0x29, 0x02, 0x83, 0x32, 0x1d, 0x91,
|
||||||
0x32, 0xce, 0x96, 0x19, 0x41, 0xa7, 0x60, 0x2f, 0xf4, 0xf1, 0x34, 0x9f, 0x33, 0x7a, 0x12, 0xfc,
|
0x85, 0xf5, 0x1c, 0x1a, 0x49, 0x9c, 0x98, 0xd1, 0x59, 0x4c, 0xd0, 0x01, 0x54, 0xa6, 0xf2, 0xc1,
|
||||||
0xa7, 0xcd, 0x41, 0xe9, 0x07, 0x36, 0x40, 0x3f, 0x82, 0xee, 0x25, 0x59, 0x8f, 0x63, 0x2a, 0x94,
|
0x64, 0x30, 0xbd, 0xf7, 0xd0, 0xbe, 0x95, 0x60, 0x3b, 0x61, 0x02, 0x2b, 0xa0, 0xd5, 0x81, 0x9d,
|
||||||
0x02, 0x2e, 0xe8, 0x2a, 0x96, 0x44, 0x2b, 0xb0, 0x4a, 0x05, 0x26, 0x75, 0x49, 0xd6, 0xe8, 0x7d,
|
0x43, 0x3a, 0x9b, 0x91, 0x31, 0xbf, 0xa5, 0x3a, 0xeb, 0x2f, 0x0d, 0x5a, 0x99, 0xab, 0x2a, 0xe0,
|
||||||
0x00, 0x9e, 0x4f, 0x53, 0x3a, 0xdb, 0x52, 0xd8, 0x2f, 0x33, 0x4a, 0xe0, 0x1f, 0x2d, 0x68, 0xbf,
|
0x39, 0x54, 0xcf, 0xc9, 0x82, 0x79, 0x41, 0x5a, 0xc1, 0x7b, 0x39, 0x2a, 0x38, 0x22, 0x8b, 0xa1,
|
||||||
0x64, 0x09, 0xb9, 0xf7, 0x88, 0x08, 0xda, 0xca, 0x66, 0x83, 0xd4, 0xdf, 0xe8, 0x3b, 0xe8, 0x5e,
|
0x17, 0x44, 0x7d, 0x7d, 0xb5, 0x34, 0xab, 0xea, 0x80, 0xd3, 0x38, 0xc8, 0x80, 0xea, 0x46, 0x17,
|
||||||
0x93, 0x35, 0x8f, 0xa9, 0xd0, 0x4e, 0x3a, 0xa3, 0x8f, 0x1a, 0x9c, 0xc1, 0x28, 0x3e, 0x73, 0x36,
|
0x70, 0x7a, 0x44, 0x8f, 0xa1, 0xcc, 0x08, 0x89, 0x62, 0xa3, 0xb8, 0x57, 0xec, 0xe8, 0xbd, 0x77,
|
||||||
0x85, 0x57, 0xc9, 0xc7, 0x15, 0x0f, 0x0a, 0xc1, 0x21, 0xcb, 0x84, 0x33, 0xba, 0x94, 0x13, 0xca,
|
0x73, 0xa4, 0x1a, 0x12, 0x12, 0xe1, 0x04, 0x85, 0xee, 0x43, 0xd1, 0x9f, 0xc5, 0x46, 0x69, 0xaf,
|
||||||
0xdd, 0xb6, 0xd6, 0x71, 0xb8, 0x29, 0x3c, 0x78, 0x6e, 0xd2, 0xd1, 0x18, 0x43, 0x55, 0x12, 0x71,
|
0xd8, 0xa9, 0xf7, 0xab, 0xab, 0xa5, 0x59, 0x1c, 0x1c, 0xbf, 0xc0, 0xc2, 0x66, 0xd9, 0x70, 0xef,
|
||||||
0xf4, 0x18, 0x0e, 0x6a, 0x00, 0x67, 0x42, 0xba, 0x9d, 0x63, 0xeb, 0xa4, 0x8d, 0xf7, 0xab, 0xe4,
|
0x60, 0xce, 0x4f, 0x69, 0x14, 0xfc, 0x44, 0x24, 0xe4, 0x16, 0x2a, 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98, 0x47, 0x6d, 0xd7, 0x66, 0x78, 0x6b, 0x03,
|
||||||
|
0x5f, 0x81, 0xbe, 0x36, 0x9c, 0xb9, 0xa2, 0x5f, 0x1f, 0xe6, 0xad, 0xd1, 0xcf, 0xa0, 0x2c, 0x5f,
|
||||||
|
0x04, 0xc8, 0xc9, 0xb9, 0xf1, 0x33, 0xa2, 0xf6, 0xf3, 0x03, 0x14, 0x4f, 0x67, 0x50, 0x4e, 0xf4,
|
||||||
|
0xe7, 0xe4, 0x5c, 0x9e, 0x77, 0xca, 0xb5, 0xa1, 0xb5, 0xbe, 0xfd, 0xdd, 0xa3, 0xdc, 0xff, 0x06,
|
||||||
|
0x3e, 0xbb, 0xe8, 0x9e, 0x54, 0x24, 0x2f, 0xef, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x85,
|
||||||
|
0x12, 0x11, 0x44, 0x0c, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
@ -785,6 +1047,10 @@ const _ = grpc.SupportPackageIsVersion4
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||||
type HeimdallClient interface {
|
type HeimdallClient interface {
|
||||||
Connect(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (*ConnectResponse, error)
|
Connect(ctx context.Context, in *ConnectRequest, opts ...grpc.CallOption) (*ConnectResponse, error)
|
||||||
|
AuthorizePeer(ctx context.Context, in *AuthorizePeerRequest, opts ...grpc.CallOption) (*types.Empty, error)
|
||||||
|
DeauthorizePeer(ctx context.Context, in *DeauthorizePeerRequest, opts ...grpc.CallOption) (*types.Empty, error)
|
||||||
|
AuthorizedPeers(ctx context.Context, in *AuthorizedPeersRequest, opts ...grpc.CallOption) (*AuthorizedPeersResponse, error)
|
||||||
|
Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*JoinResponse, error)
|
||||||
Routes(ctx context.Context, in *RoutesRequest, opts ...grpc.CallOption) (*RoutesResponse, error)
|
Routes(ctx context.Context, in *RoutesRequest, opts ...grpc.CallOption) (*RoutesResponse, error)
|
||||||
CreateRoute(ctx context.Context, in *CreateRouteRequest, opts ...grpc.CallOption) (*types.Empty, error)
|
CreateRoute(ctx context.Context, in *CreateRouteRequest, opts ...grpc.CallOption) (*types.Empty, error)
|
||||||
DeleteRoute(ctx context.Context, in *DeleteRouteRequest, opts ...grpc.CallOption) (*types.Empty, error)
|
DeleteRoute(ctx context.Context, in *DeleteRouteRequest, opts ...grpc.CallOption) (*types.Empty, error)
|
||||||
|
@ -809,6 +1075,42 @@ func (c *heimdallClient) Connect(ctx context.Context, in *ConnectRequest, opts .
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *heimdallClient) AuthorizePeer(ctx context.Context, in *AuthorizePeerRequest, opts ...grpc.CallOption) (*types.Empty, error) {
|
||||||
|
out := new(types.Empty)
|
||||||
|
err := c.cc.Invoke(ctx, "/io.stellarproject.heimdall.api.v1.Heimdall/AuthorizePeer", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *heimdallClient) DeauthorizePeer(ctx context.Context, in *DeauthorizePeerRequest, opts ...grpc.CallOption) (*types.Empty, error) {
|
||||||
|
out := new(types.Empty)
|
||||||
|
err := c.cc.Invoke(ctx, "/io.stellarproject.heimdall.api.v1.Heimdall/DeauthorizePeer", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *heimdallClient) AuthorizedPeers(ctx context.Context, in *AuthorizedPeersRequest, opts ...grpc.CallOption) (*AuthorizedPeersResponse, error) {
|
||||||
|
out := new(AuthorizedPeersResponse)
|
||||||
|
err := c.cc.Invoke(ctx, "/io.stellarproject.heimdall.api.v1.Heimdall/AuthorizedPeers", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *heimdallClient) Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*JoinResponse, error) {
|
||||||
|
out := new(JoinResponse)
|
||||||
|
err := c.cc.Invoke(ctx, "/io.stellarproject.heimdall.api.v1.Heimdall/Join", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *heimdallClient) Routes(ctx context.Context, in *RoutesRequest, opts ...grpc.CallOption) (*RoutesResponse, error) {
|
func (c *heimdallClient) Routes(ctx context.Context, in *RoutesRequest, opts ...grpc.CallOption) (*RoutesResponse, error) {
|
||||||
out := new(RoutesResponse)
|
out := new(RoutesResponse)
|
||||||
err := c.cc.Invoke(ctx, "/io.stellarproject.heimdall.api.v1.Heimdall/Routes", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/io.stellarproject.heimdall.api.v1.Heimdall/Routes", in, out, opts...)
|
||||||
|
@ -857,6 +1159,10 @@ func (c *heimdallClient) Peers(ctx context.Context, in *PeersRequest, opts ...gr
|
||||||
// HeimdallServer is the server API for Heimdall service.
|
// HeimdallServer is the server API for Heimdall service.
|
||||||
type HeimdallServer interface {
|
type HeimdallServer interface {
|
||||||
Connect(context.Context, *ConnectRequest) (*ConnectResponse, error)
|
Connect(context.Context, *ConnectRequest) (*ConnectResponse, error)
|
||||||
|
AuthorizePeer(context.Context, *AuthorizePeerRequest) (*types.Empty, error)
|
||||||
|
DeauthorizePeer(context.Context, *DeauthorizePeerRequest) (*types.Empty, error)
|
||||||
|
AuthorizedPeers(context.Context, *AuthorizedPeersRequest) (*AuthorizedPeersResponse, error)
|
||||||
|
Join(context.Context, *JoinRequest) (*JoinResponse, error)
|
||||||
Routes(context.Context, *RoutesRequest) (*RoutesResponse, error)
|
Routes(context.Context, *RoutesRequest) (*RoutesResponse, error)
|
||||||
CreateRoute(context.Context, *CreateRouteRequest) (*types.Empty, error)
|
CreateRoute(context.Context, *CreateRouteRequest) (*types.Empty, error)
|
||||||
DeleteRoute(context.Context, *DeleteRouteRequest) (*types.Empty, error)
|
DeleteRoute(context.Context, *DeleteRouteRequest) (*types.Empty, error)
|
||||||
|
@ -871,6 +1177,18 @@ type UnimplementedHeimdallServer struct {
|
||||||
func (*UnimplementedHeimdallServer) Connect(ctx context.Context, req *ConnectRequest) (*ConnectResponse, error) {
|
func (*UnimplementedHeimdallServer) Connect(ctx context.Context, req *ConnectRequest) (*ConnectResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Connect not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Connect not implemented")
|
||||||
}
|
}
|
||||||
|
func (*UnimplementedHeimdallServer) AuthorizePeer(ctx context.Context, req *AuthorizePeerRequest) (*types.Empty, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method AuthorizePeer not implemented")
|
||||||
|
}
|
||||||
|
func (*UnimplementedHeimdallServer) DeauthorizePeer(ctx context.Context, req *DeauthorizePeerRequest) (*types.Empty, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DeauthorizePeer not implemented")
|
||||||
|
}
|
||||||
|
func (*UnimplementedHeimdallServer) AuthorizedPeers(ctx context.Context, req *AuthorizedPeersRequest) (*AuthorizedPeersResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method AuthorizedPeers not implemented")
|
||||||
|
}
|
||||||
|
func (*UnimplementedHeimdallServer) Join(ctx context.Context, req *JoinRequest) (*JoinResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Join not implemented")
|
||||||
|
}
|
||||||
func (*UnimplementedHeimdallServer) Routes(ctx context.Context, req *RoutesRequest) (*RoutesResponse, error) {
|
func (*UnimplementedHeimdallServer) Routes(ctx context.Context, req *RoutesRequest) (*RoutesResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Routes not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Routes not implemented")
|
||||||
}
|
}
|
||||||
|
@ -909,6 +1227,78 @@ func _Heimdall_Connect_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Heimdall_AuthorizePeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(AuthorizePeerRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(HeimdallServer).AuthorizePeer(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/io.stellarproject.heimdall.api.v1.Heimdall/AuthorizePeer",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(HeimdallServer).AuthorizePeer(ctx, req.(*AuthorizePeerRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Heimdall_DeauthorizePeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DeauthorizePeerRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(HeimdallServer).DeauthorizePeer(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/io.stellarproject.heimdall.api.v1.Heimdall/DeauthorizePeer",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(HeimdallServer).DeauthorizePeer(ctx, req.(*DeauthorizePeerRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Heimdall_AuthorizedPeers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(AuthorizedPeersRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(HeimdallServer).AuthorizedPeers(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/io.stellarproject.heimdall.api.v1.Heimdall/AuthorizedPeers",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(HeimdallServer).AuthorizedPeers(ctx, req.(*AuthorizedPeersRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Heimdall_Join_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(JoinRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(HeimdallServer).Join(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/io.stellarproject.heimdall.api.v1.Heimdall/Join",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(HeimdallServer).Join(ctx, req.(*JoinRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
func _Heimdall_Routes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Heimdall_Routes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(RoutesRequest)
|
in := new(RoutesRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
|
@ -1007,6 +1397,22 @@ var _Heimdall_serviceDesc = grpc.ServiceDesc{
|
||||||
MethodName: "Connect",
|
MethodName: "Connect",
|
||||||
Handler: _Heimdall_Connect_Handler,
|
Handler: _Heimdall_Connect_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "AuthorizePeer",
|
||||||
|
Handler: _Heimdall_AuthorizePeer_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "DeauthorizePeer",
|
||||||
|
Handler: _Heimdall_DeauthorizePeer_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "AuthorizedPeers",
|
||||||
|
Handler: _Heimdall_AuthorizedPeers_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Join",
|
||||||
|
Handler: _Heimdall_Join_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "Routes",
|
MethodName: "Routes",
|
||||||
Handler: _Heimdall_Routes_Handler,
|
Handler: _Heimdall_Routes_Handler,
|
||||||
|
|
|
@ -10,6 +10,10 @@ option go_package = "github.com/stellarproject/heimdall/api/v1;v1";
|
||||||
|
|
||||||
service Heimdall {
|
service Heimdall {
|
||||||
rpc Connect(ConnectRequest) returns (ConnectResponse);
|
rpc Connect(ConnectRequest) returns (ConnectResponse);
|
||||||
|
rpc AuthorizePeer(AuthorizePeerRequest) returns (google.protobuf.Empty);
|
||||||
|
rpc DeauthorizePeer(DeauthorizePeerRequest) returns (google.protobuf.Empty);
|
||||||
|
rpc AuthorizedPeers(AuthorizedPeersRequest) returns (AuthorizedPeersResponse);
|
||||||
|
rpc Join(JoinRequest) returns (JoinResponse);
|
||||||
rpc Routes(RoutesRequest) returns (RoutesResponse);
|
rpc Routes(RoutesRequest) returns (RoutesResponse);
|
||||||
rpc CreateRoute(CreateRouteRequest) returns (google.protobuf.Empty);
|
rpc CreateRoute(CreateRouteRequest) returns (google.protobuf.Empty);
|
||||||
rpc DeleteRoute(DeleteRouteRequest) returns (google.protobuf.Empty);
|
rpc DeleteRoute(DeleteRouteRequest) returns (google.protobuf.Empty);
|
||||||
|
@ -23,15 +27,40 @@ message Master {
|
||||||
string redis_url = 3 [(gogoproto.customname) = "RedisURL"];
|
string redis_url = 3 [(gogoproto.customname) = "RedisURL"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConnectRequest {
|
message JoinRequest {
|
||||||
string id = 1 [(gogoproto.customname) = "ID"];
|
string id = 1 [(gogoproto.customname) = "ID"];
|
||||||
string cluster_key = 2;
|
string cluster_key = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConnectResponse {
|
message JoinResponse {
|
||||||
Master master = 1;
|
Master master = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ConnectRequest {
|
||||||
|
string id = 1 [(gogoproto.customname) = "ID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message ConnectResponse {
|
||||||
|
KeyPair keypair = 1 [(gogoproto.customname) = "KeyPair"];
|
||||||
|
string address = 2;
|
||||||
|
repeated Peer peers = 3;
|
||||||
|
repeated string dns = 4 [(gogoproto.customname) = "DNS"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message AuthorizePeerRequest {
|
||||||
|
string id = 1 [(gogoproto.customname) = "ID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeauthorizePeerRequest {
|
||||||
|
string id = 1 [(gogoproto.customname) = "ID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message AuthorizedPeersRequest {}
|
||||||
|
|
||||||
|
message AuthorizedPeersResponse {
|
||||||
|
repeated string ids = 1 [(gogoproto.customname) = "IDs"];
|
||||||
|
}
|
||||||
|
|
||||||
message KeyPair {
|
message KeyPair {
|
||||||
string private_key = 1;
|
string private_key = 1;
|
||||||
string public_key = 2;
|
string public_key = 2;
|
||||||
|
|
|
@ -27,16 +27,42 @@ import (
|
||||||
v1 "github.com/stellarproject/heimdall/api/v1"
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Connect attempts to connect to the peer and returns the master info
|
// AuthorizePeer authorizes a new peer to the cluster
|
||||||
func (c *Client) Connect(key string) (*v1.Master, error) {
|
func (c *Client) AuthorizePeer(id string) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
resp, err := c.heimdallClient.Connect(ctx, &v1.ConnectRequest{
|
if _, err := c.heimdallClient.AuthorizePeer(ctx, &v1.AuthorizePeerRequest{
|
||||||
ID: c.id,
|
ID: id,
|
||||||
ClusterKey: key,
|
}); err != nil {
|
||||||
})
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeauthorizePeer removes a peer from the cluster
|
||||||
|
func (c *Client) DeauthorizePeer(id string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
if _, err := c.heimdallClient.DeauthorizePeer(ctx, &v1.DeauthorizePeerRequest{
|
||||||
|
ID: id,
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizedPeers returns a list of authorized peers
|
||||||
|
func (c *Client) AuthorizedPeers() ([]string, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := c.heimdallClient.AuthorizedPeers(ctx, &v1.AuthorizedPeersRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return resp.IDs, nil
|
||||||
return resp.Master, nil
|
}
|
||||||
|
|
||||||
|
// Connect requests to connect a peer to the cluster
|
||||||
|
func (c *Client) Connect() (*v1.ConnectResponse, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
return c.heimdallClient.Connect(ctx, &v1.ConnectRequest{
|
||||||
|
ID: c.id,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
42
client/join.go
Normal file
42
client/join.go
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Stellar Project
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Join attempts to connect to the peer and returns the master info
|
||||||
|
func (c *Client) Join(key string) (*v1.Master, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := c.heimdallClient.Join(ctx, &v1.JoinRequest{
|
||||||
|
ID: c.id,
|
||||||
|
ClusterKey: key,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.Master, nil
|
||||||
|
}
|
|
@ -34,8 +34,12 @@ var peersCommand = cli.Command{
|
||||||
Usage: "peer management",
|
Usage: "peer management",
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
listPeersCommand,
|
listPeersCommand,
|
||||||
|
authorizedPeersCommand,
|
||||||
|
authorizePeerCommand,
|
||||||
|
deauthorizePeerCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var listPeersCommand = cli.Command{
|
var listPeersCommand = cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "list peers",
|
Usage: "list peers",
|
||||||
|
@ -61,3 +65,57 @@ var listPeersCommand = cli.Command{
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var authorizedPeersCommand = cli.Command{
|
||||||
|
Name: "authorized",
|
||||||
|
Usage: "authorized peers in the cluster",
|
||||||
|
Action: func(cx *cli.Context) error {
|
||||||
|
c, err := getClient(cx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
ids, err := c.AuthorizedPeers()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
||||||
|
fmt.Fprintf(w, "ID\n")
|
||||||
|
for _, id := range ids {
|
||||||
|
fmt.Fprintf(w, "%s\n", id)
|
||||||
|
}
|
||||||
|
w.Flush()
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var authorizePeerCommand = cli.Command{
|
||||||
|
Name: "authorize",
|
||||||
|
Usage: "authorize peer to cluster",
|
||||||
|
Action: func(cx *cli.Context) error {
|
||||||
|
c, err := getClient(cx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
id := cx.Args().First()
|
||||||
|
return c.AuthorizePeer(id)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var deauthorizePeerCommand = cli.Command{
|
||||||
|
Name: "deauthorize",
|
||||||
|
Usage: "deauthorize peer from cluster",
|
||||||
|
Action: func(cx *cli.Context) error {
|
||||||
|
c, err := getClient(cx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
id := cx.Args().First()
|
||||||
|
return c.DeauthorizePeer(id)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -107,6 +107,12 @@ func main() {
|
||||||
Value: 10100,
|
Value: 10100,
|
||||||
EnvVar: "HEIMDALL_ENDPOINT_PORT",
|
EnvVar: "HEIMDALL_ENDPOINT_PORT",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "interface-name",
|
||||||
|
Usage: "interface name to use for peer communication (must not exist)",
|
||||||
|
Value: "darknet",
|
||||||
|
EnvVar: "HEIMDALL_INTERFACE_NAME",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
app.Before = func(c *cli.Context) error {
|
app.Before = func(c *cli.Context) error {
|
||||||
if c.Bool("debug") {
|
if c.Bool("debug") {
|
||||||
|
|
|
@ -49,6 +49,7 @@ func runServer(cx *cli.Context) error {
|
||||||
PeerNetwork: cx.String("peer-network"),
|
PeerNetwork: cx.String("peer-network"),
|
||||||
EndpointIP: cx.String("endpoint-ip"),
|
EndpointIP: cx.String("endpoint-ip"),
|
||||||
EndpointPort: cx.Int("endpoint-port"),
|
EndpointPort: cx.Int("endpoint-port"),
|
||||||
|
InterfaceName: cx.String("interface-name"),
|
||||||
RedisURL: cx.String("redis-url"),
|
RedisURL: cx.String("redis-url"),
|
||||||
AdvertiseRedisURL: cx.String("advertise-redis-url"),
|
AdvertiseRedisURL: cx.String("advertise-redis-url"),
|
||||||
}
|
}
|
||||||
|
|
96
cmd/hpeer/main.go
Normal file
96
cmd/hpeer/main.go
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Stellar Project
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/stellarproject/heimdall"
|
||||||
|
"github.com/stellarproject/heimdall/version"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Name = "hpeer"
|
||||||
|
app.Version = version.BuildVersion()
|
||||||
|
app.Author = "@stellarproject"
|
||||||
|
app.Email = ""
|
||||||
|
app.Usage = version.Description
|
||||||
|
app.Flags = []cli.Flag{
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "debug, D",
|
||||||
|
Usage: "Enable debug logging",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "id",
|
||||||
|
Usage: "peer id for cluster",
|
||||||
|
Value: heimdall.NodeID(),
|
||||||
|
EnvVar: "HEIMDALL_ID",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "addr",
|
||||||
|
Usage: "heimdall peer address to join",
|
||||||
|
Value: "tcp://127.0.0.1:9000",
|
||||||
|
EnvVar: "HEIMDALL_ADDR",
|
||||||
|
},
|
||||||
|
cli.DurationFlag{
|
||||||
|
Name: "update-interval",
|
||||||
|
Usage: "interval in which to update with the cluster",
|
||||||
|
Value: time.Second * 10,
|
||||||
|
EnvVar: "HEIMDALL_UPDATE_INTERVAL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "interface-name",
|
||||||
|
Usage: "interface name to use for peer communication (must not exist)",
|
||||||
|
Value: "darknet",
|
||||||
|
EnvVar: "HEIMDALL_INTERFACE_NAME",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cert, c",
|
||||||
|
Usage: "heimdall client certificate",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "key, k",
|
||||||
|
Usage: "heimdall client key",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-verify",
|
||||||
|
Usage: "skip TLS verification",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
app.Before = func(c *cli.Context) error {
|
||||||
|
if c.Bool("debug") {
|
||||||
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
app.Action = run
|
||||||
|
|
||||||
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
89
cmd/hpeer/run.go
Normal file
89
cmd/hpeer/run.go
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Stellar Project
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/stellarproject/heimdall"
|
||||||
|
"github.com/stellarproject/heimdall/peer"
|
||||||
|
"github.com/stellarproject/heimdall/version"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func run(cx *cli.Context) error {
|
||||||
|
cfg := &heimdall.PeerConfig{
|
||||||
|
ID: cx.String("id"),
|
||||||
|
Address: cx.String("addr"),
|
||||||
|
UpdateInterval: cx.Duration("update-interval"),
|
||||||
|
InterfaceName: cx.String("interface-name"),
|
||||||
|
}
|
||||||
|
p, err := peer.NewPeer(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
errCh := make(chan error, 1)
|
||||||
|
|
||||||
|
signals := make(chan os.Signal)
|
||||||
|
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)
|
||||||
|
doneCh := make(chan bool, 1)
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case sig := <-signals:
|
||||||
|
switch sig {
|
||||||
|
case syscall.SIGTERM, syscall.SIGINT:
|
||||||
|
logrus.Info("shutting down")
|
||||||
|
if err := p.Stop(); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
}
|
||||||
|
doneCh <- true
|
||||||
|
default:
|
||||||
|
logrus.Warnf("unhandled signal %s", sig)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
logrus.WithFields(logrus.Fields{
|
||||||
|
"version": version.Version,
|
||||||
|
"commit": version.GitCommit,
|
||||||
|
}).Infof("starting %s", version.Name)
|
||||||
|
go func() {
|
||||||
|
if err := p.Run(); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-doneCh:
|
||||||
|
return nil
|
||||||
|
case err := <-errCh:
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
16
config.go
16
config.go
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
package heimdall
|
package heimdall
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
// Config is the configuration used for the stellar server
|
// Config is the configuration used for the stellar server
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// ID is the id of the node
|
// ID is the id of the node
|
||||||
|
@ -39,6 +41,8 @@ type Config struct {
|
||||||
EndpointIP string
|
EndpointIP string
|
||||||
// GatewayPort is the port used for peer communication
|
// GatewayPort is the port used for peer communication
|
||||||
EndpointPort int
|
EndpointPort int
|
||||||
|
// InterfaceName is the interface used for peer communication
|
||||||
|
InterfaceName string
|
||||||
// RedisURL is the uri to the redis backend
|
// RedisURL is the uri to the redis backend
|
||||||
RedisURL string
|
RedisURL string
|
||||||
// AdvertiseRedisURL is the uri to the public redis backend
|
// AdvertiseRedisURL is the uri to the public redis backend
|
||||||
|
@ -54,3 +58,15 @@ type Config struct {
|
||||||
// TLSInsecureSkipVerify disables certificate verification
|
// TLSInsecureSkipVerify disables certificate verification
|
||||||
TLSInsecureSkipVerify bool
|
TLSInsecureSkipVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PeerConfig is the configuration of the peer
|
||||||
|
type PeerConfig struct {
|
||||||
|
// ID is the id of the peer
|
||||||
|
ID string
|
||||||
|
// Address is the GRPC address of the peer to join
|
||||||
|
Address string
|
||||||
|
// UpdateInterval is the interval in which to update with the cluster
|
||||||
|
UpdateInterval time.Duration
|
||||||
|
// InterfaceName is the interface used for peer communication
|
||||||
|
InterfaceName string
|
||||||
|
}
|
||||||
|
|
93
peer/peer.go
Normal file
93
peer/peer.go
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Stellar Project
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package peer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/stellarproject/heimdall"
|
||||||
|
"github.com/stellarproject/heimdall/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
wireguardConfigDir = "/etc/wireguard"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Peer is the non-node peer
|
||||||
|
type Peer struct {
|
||||||
|
cfg *heimdall.PeerConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPeer returns a new peer
|
||||||
|
func NewPeer(cfg *heimdall.PeerConfig) (*Peer, error) {
|
||||||
|
return &Peer{
|
||||||
|
cfg: cfg,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run starts the peer
|
||||||
|
func (p *Peer) Run() error {
|
||||||
|
// initial sync
|
||||||
|
logrus.Infof("connecting to peer %s", p.cfg.Address)
|
||||||
|
if err := p.sync(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
doneCh := make(chan bool)
|
||||||
|
errCh := make(chan error)
|
||||||
|
|
||||||
|
t := time.NewTicker(p.cfg.UpdateInterval)
|
||||||
|
go func() {
|
||||||
|
for range t.C {
|
||||||
|
if err := p.sync(); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-doneCh:
|
||||||
|
case err := <-errCh:
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop stops the peer
|
||||||
|
func (p *Peer) Stop() error {
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Peer) getWireguardConfigPath() string {
|
||||||
|
return filepath.Join(wireguardConfigDir, p.cfg.InterfaceName+".conf")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Peer) getTunnelName() string {
|
||||||
|
return p.cfg.InterfaceName
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Peer) getClient(addr string) (*client.Client, error) {
|
||||||
|
return client.NewClient(p.cfg.ID, addr)
|
||||||
|
}
|
99
peer/sync.go
Normal file
99
peer/sync.go
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Stellar Project
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package peer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/stellarproject/heimdall"
|
||||||
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
|
"github.com/stellarproject/heimdall/wg"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *Peer) sync() error {
|
||||||
|
c, err := p.getClient(p.cfg.Address)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
resp, err := c.Connect()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
peers := []*v1.Peer{}
|
||||||
|
for _, peer := range resp.Peers {
|
||||||
|
// don't add self
|
||||||
|
if peer.ID == p.cfg.ID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
peers = append(peers, peer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate wireguard config
|
||||||
|
wireguardCfg := &wg.Config{
|
||||||
|
Iface: p.cfg.InterfaceName,
|
||||||
|
Address: resp.Address,
|
||||||
|
PrivateKey: resp.KeyPair.PrivateKey,
|
||||||
|
Peers: peers,
|
||||||
|
DNS: resp.DNS,
|
||||||
|
}
|
||||||
|
|
||||||
|
wireguardConfigPath := p.getWireguardConfigPath()
|
||||||
|
tmpCfg, err := wg.GeneratePeerConfig(wireguardCfg, wireguardConfigPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
h, err := heimdall.HashConfig(tmpCfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
e, err := heimdall.HashConfig(wireguardConfigPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// if config has not change skip update
|
||||||
|
if h == e {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("updating peer config to version %s", h)
|
||||||
|
// update wireguard config
|
||||||
|
if err := os.Rename(tmpCfg, wireguardConfigPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// reload wireguard
|
||||||
|
if err := wg.RestartTunnel(ctx, p.getTunnelName()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -25,42 +25,86 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
ptypes "github.com/gogo/protobuf/types"
|
||||||
"github.com/gomodule/redigo/redis"
|
"github.com/gomodule/redigo/redis"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
v1 "github.com/stellarproject/heimdall/api/v1"
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrInvalidAuth is returned when an invalid cluster key is specified upon connect
|
// ErrAccessDenied is returned when an unauthorized non-node peer attempts to join
|
||||||
ErrInvalidAuth = errors.New("invalid cluster key specified")
|
ErrAccessDenied = errors.New("access denied")
|
||||||
// ErrNoMaster is returned if there is no configured master yet
|
|
||||||
ErrNoMaster = errors.New("no configured master")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Connect is called when a peer wants to connect to the node
|
func (s *Server) AuthorizedPeers(ctx context.Context, req *v1.AuthorizedPeersRequest) (*v1.AuthorizedPeersResponse, error) {
|
||||||
func (s *Server) Connect(ctx context.Context, req *v1.ConnectRequest) (*v1.ConnectResponse, error) {
|
authorized, err := redis.Strings(s.local(ctx, "SMEMBERS", authorizedPeersKey))
|
||||||
logrus.Debugf("connect request from %s", req.ID)
|
|
||||||
key, err := s.getClusterKey(ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if req.ClusterKey != key {
|
return &v1.AuthorizedPeersResponse{
|
||||||
return nil, ErrInvalidAuth
|
IDs: authorized,
|
||||||
}
|
}, nil
|
||||||
data, err := redis.Bytes(s.local(ctx, "GET", masterKey))
|
}
|
||||||
if err != nil {
|
|
||||||
if err == redis.ErrNil {
|
// AuthorizePeer authorizes a peer to the cluster
|
||||||
return nil, ErrNoMaster
|
func (s *Server) AuthorizePeer(ctx context.Context, req *v1.AuthorizePeerRequest) (*ptypes.Empty, error) {
|
||||||
}
|
logrus.Debugf("authorizing peer %s", req.ID)
|
||||||
return nil, err
|
if _, err := s.master(ctx, "SADD", authorizedPeersKey, req.ID); err != nil {
|
||||||
}
|
return nil, err
|
||||||
var master v1.Master
|
}
|
||||||
if err := proto.Unmarshal(data, &master); err != nil {
|
logrus.Infof("authorized peer %s", req.ID)
|
||||||
return nil, err
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &v1.ConnectResponse{
|
// DeauthorizePeer deauthorizes a peer from the cluster
|
||||||
Master: &master,
|
func (s *Server) DeauthorizePeer(ctx context.Context, req *v1.DeauthorizePeerRequest) (*ptypes.Empty, error) {
|
||||||
|
logrus.Debugf("deauthorizing peer %s", req.ID)
|
||||||
|
if _, err := s.master(ctx, "SREM", authorizedPeersKey, req.ID); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
logrus.Infof("deauthorized peer %s", req.ID)
|
||||||
|
return empty, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect is called when a non-node peer wants to connect to the cluster
|
||||||
|
func (s *Server) Connect(ctx context.Context, req *v1.ConnectRequest) (*v1.ConnectResponse, error) {
|
||||||
|
authorized, err := redis.Bool(s.local(ctx, "SISMEMBER", authorizedPeersKey, req.ID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !authorized {
|
||||||
|
logrus.Warnf("unauthorized request attempt from %s", req.ID)
|
||||||
|
return nil, ErrAccessDenied
|
||||||
|
}
|
||||||
|
keyPair, err := s.getOrCreateKeyPair(ctx, req.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nodes, err := s.getNodes(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dnsAddrs := []string{}
|
||||||
|
for _, n := range nodes {
|
||||||
|
dnsAddrs = append(dnsAddrs, n.GatewayIP)
|
||||||
|
}
|
||||||
|
|
||||||
|
peers, err := s.getPeers(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ip, _, err := s.getOrAllocatePeerIP(ctx, req.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := s.updatePeerInfo(ctx, req.ID); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// save peer
|
||||||
|
return &v1.ConnectResponse{
|
||||||
|
KeyPair: keyPair,
|
||||||
|
Address: ip.String() + "/32",
|
||||||
|
Peers: peers,
|
||||||
|
DNS: dnsAddrs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
66
server/join.go
Normal file
66
server/join.go
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Stellar Project
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/gogo/protobuf/proto"
|
||||||
|
"github.com/gomodule/redigo/redis"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrInvalidAuth is returned when an invalid cluster key is specified upon connect
|
||||||
|
ErrInvalidAuth = errors.New("invalid cluster key specified")
|
||||||
|
// ErrNoMaster is returned if there is no configured master yet
|
||||||
|
ErrNoMaster = errors.New("no configured master")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Join is called when a peer wants to join the cluster
|
||||||
|
func (s *Server) Join(ctx context.Context, req *v1.JoinRequest) (*v1.JoinResponse, error) {
|
||||||
|
logrus.Debugf("join request from %s", req.ID)
|
||||||
|
key, err := s.getClusterKey(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if req.ClusterKey != key {
|
||||||
|
return nil, ErrInvalidAuth
|
||||||
|
}
|
||||||
|
data, err := redis.Bytes(s.local(ctx, "GET", masterKey))
|
||||||
|
if err != nil {
|
||||||
|
if err == redis.ErrNil {
|
||||||
|
return nil, ErrNoMaster
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var master v1.Master
|
||||||
|
if err := proto.Unmarshal(data, &master); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.JoinResponse{
|
||||||
|
Master: &master,
|
||||||
|
}, nil
|
||||||
|
}
|
|
@ -109,7 +109,7 @@ func (s *Server) configureNode() error {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m, err := c.Connect(s.cfg.ClusterKey)
|
m, err := c.Join(s.cfg.ClusterKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Close()
|
c.Close()
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
|
|
|
@ -23,16 +23,16 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/gomodule/redigo/redis"
|
"github.com/gomodule/redigo/redis"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/stellarproject/heimdall"
|
||||||
v1 "github.com/stellarproject/heimdall/api/v1"
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
|
"github.com/stellarproject/heimdall/wg"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Peers returns a list of known peers
|
// Peers returns a list of known peers
|
||||||
|
@ -74,8 +74,8 @@ func (s *Server) peerUpdater(ctx context.Context) {
|
||||||
|
|
||||||
for range t.C {
|
for range t.C {
|
||||||
uctx, cancel := context.WithTimeout(ctx, peerConfigUpdateInterval)
|
uctx, cancel := context.WithTimeout(ctx, peerConfigUpdateInterval)
|
||||||
if err := s.updatePeerInfo(uctx); err != nil {
|
if err := s.updatePeerInfo(uctx, s.cfg.ID); err != nil {
|
||||||
logrus.Errorf("updatePeerInfo: %s", err)
|
logrus.Errorf("updateLocalPeerInfo: %s", err)
|
||||||
cancel()
|
cancel()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -89,16 +89,24 @@ func (s *Server) peerUpdater(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) updatePeerInfo(ctx context.Context) error {
|
func (s *Server) updatePeerInfo(ctx context.Context, id string) error {
|
||||||
keypair, err := s.getOrCreateKeyPair(ctx, s.cfg.ID)
|
keypair, err := s.getOrCreateKeyPair(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint := fmt.Sprintf("%s:%d", s.cfg.EndpointIP, s.cfg.EndpointPort)
|
endpoint, err := s.getPeerEndpoint(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// build allowedIPs from routes and peer network
|
// build allowedIPs from routes and peer network
|
||||||
allowedIPs := []string{}
|
allowedIPs := []string{}
|
||||||
|
|
||||||
|
// add peer net
|
||||||
|
if endpoint == "" {
|
||||||
|
allowedIPs = append(allowedIPs, s.cfg.PeerNetwork)
|
||||||
|
}
|
||||||
nodes, err := s.getNodes(ctx)
|
nodes, err := s.getNodes(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -106,7 +114,7 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
// only add the route if a peer to prevent route duplicate
|
// only add the route if a peer to prevent route duplicate
|
||||||
if node.ID != s.cfg.ID {
|
if node.ID != id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,17 +132,16 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
// only add the route if a peer to prevent route duplicate
|
// only add the route if a peer to prevent route blackhole
|
||||||
if route.NodeID != s.cfg.ID {
|
if route.NodeID != id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("adding route to allowed IPs: %s", route.Network)
|
|
||||||
allowedIPs = append(allowedIPs, route.Network)
|
allowedIPs = append(allowedIPs, route.Network)
|
||||||
}
|
}
|
||||||
|
|
||||||
n := &v1.Peer{
|
n := &v1.Peer{
|
||||||
ID: s.cfg.ID,
|
ID: id,
|
||||||
KeyPair: keypair,
|
KeyPair: keypair,
|
||||||
AllowedIPs: allowedIPs,
|
AllowedIPs: allowedIPs,
|
||||||
Endpoint: endpoint,
|
Endpoint: endpoint,
|
||||||
|
@ -144,9 +151,9 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pHash := hashData(data)
|
pHash := heimdall.HashData(data)
|
||||||
|
|
||||||
key := s.getPeerKey(s.cfg.ID)
|
key := s.getPeerKey(id)
|
||||||
peerData, err := redis.Bytes(s.local(ctx, "GET", key))
|
peerData, err := redis.Bytes(s.local(ctx, "GET", key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != redis.ErrNil {
|
if err != redis.ErrNil {
|
||||||
|
@ -154,7 +161,7 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eHash := hashData(peerData)
|
eHash := heimdall.HashData(peerData)
|
||||||
|
|
||||||
// skip update if same
|
// skip update if same
|
||||||
if pHash == eHash {
|
if pHash == eHash {
|
||||||
|
@ -165,11 +172,25 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("peer info: endpoint=%s allowedips=%+v", n.Endpoint, n.Endpoint)
|
logrus.Debugf("peer info updated: id=%s", id)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) getPeerEndpoint(ctx context.Context, id string) (string, error) {
|
||||||
|
node, err := s.getNode(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
if err == redis.ErrNil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if node == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s:%d", node.EndpointIP, node.EndpointPort), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) getPeerInfo(ctx context.Context, id string) (*v1.Peer, error) {
|
func (s *Server) getPeerInfo(ctx context.Context, id string) (*v1.Peer, error) {
|
||||||
key := s.getPeerKey(id)
|
key := s.getPeerKey(id)
|
||||||
data, err := redis.Bytes(s.local(ctx, "GET", key))
|
data, err := redis.Bytes(s.local(ctx, "GET", key))
|
||||||
|
@ -222,25 +243,26 @@ func (s *Server) updatePeerConfig(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
size, _ := gatewayNet.Mask.Size()
|
size, _ := gatewayNet.Mask.Size()
|
||||||
wireguardCfg := &wireguardConfig{
|
wireguardCfg := &wg.Config{
|
||||||
Iface: defaultWireguardInterface,
|
Iface: s.cfg.InterfaceName,
|
||||||
PrivateKey: keyPair.PrivateKey,
|
PrivateKey: keyPair.PrivateKey,
|
||||||
ListenPort: s.cfg.EndpointPort,
|
ListenPort: s.cfg.EndpointPort,
|
||||||
Address: fmt.Sprintf("%s/%d", gatewayIP.To4().String(), size),
|
Address: fmt.Sprintf("%s/%d", gatewayIP.To4().String(), size),
|
||||||
Peers: peers,
|
Peers: peers,
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpCfg, err := generateNodeWireguardConfig(wireguardCfg)
|
wireguardConfigPath := s.getWireguardConfigPath()
|
||||||
|
tmpCfg, err := wg.GenerateNodeConfig(wireguardCfg, wireguardConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
h, err := hashConfig(tmpCfg)
|
h, err := heimdall.HashConfig(tmpCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err := hashConfig(wireguardConfigPath)
|
e, err := heimdall.HashConfig(wireguardConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -257,30 +279,9 @@ func (s *Server) updatePeerConfig(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reload wireguard
|
// reload wireguard
|
||||||
if err := restartWireguardTunnel(ctx); err != nil {
|
if err := wg.RestartTunnel(ctx, s.getTunnelName()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hashData(data []byte) string {
|
|
||||||
h := sha256.New()
|
|
||||||
h.Write(data)
|
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
|
||||||
}
|
|
||||||
|
|
||||||
func hashConfig(cfgPath string) (string, error) {
|
|
||||||
if _, err := os.Stat(cfgPath); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
peerData, err := ioutil.ReadFile(cfgPath)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashData(peerData), nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"time"
|
"time"
|
||||||
|
@ -37,22 +38,24 @@ import (
|
||||||
"github.com/stellarproject/heimdall"
|
"github.com/stellarproject/heimdall"
|
||||||
v1 "github.com/stellarproject/heimdall/api/v1"
|
v1 "github.com/stellarproject/heimdall/api/v1"
|
||||||
"github.com/stellarproject/heimdall/client"
|
"github.com/stellarproject/heimdall/client"
|
||||||
|
"github.com/stellarproject/heimdall/wg"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
masterKey = "heimdall:master"
|
masterKey = "heimdall:master"
|
||||||
clusterKey = "heimdall:key"
|
clusterKey = "heimdall:key"
|
||||||
keypairsKey = "heimdall:keypairs"
|
keypairsKey = "heimdall:keypairs"
|
||||||
nodesKey = "heimdall:nodes"
|
nodesKey = "heimdall:nodes"
|
||||||
nodeJoinKey = "heimdall:join"
|
nodeJoinKey = "heimdall:join"
|
||||||
peersKey = "heimdall:peers"
|
peersKey = "heimdall:peers"
|
||||||
routesKey = "heimdall:routes"
|
routesKey = "heimdall:routes"
|
||||||
peerIPsKey = "heimdall:peerips"
|
peerIPsKey = "heimdall:peerips"
|
||||||
nodeIPsKey = "heimdall:nodeips"
|
nodeIPsKey = "heimdall:nodeips"
|
||||||
nodeNetworksKey = "heimdall:nodenetworks"
|
nodeNetworksKey = "heimdall:nodenetworks"
|
||||||
|
authorizedPeersKey = "heimdall:authorized"
|
||||||
|
|
||||||
wireguardConfigPath = "/etc/wireguard/darknet.conf"
|
wireguardConfigDir = "/etc/wireguard"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -118,7 +121,7 @@ func (s *Server) Run() error {
|
||||||
}
|
}
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
master, err := c.Connect(s.cfg.ClusterKey)
|
master, err := c.Join(s.cfg.ClusterKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,7 @@ func (s *Server) Run() error {
|
||||||
go s.nodeHeartbeat(ctx)
|
go s.nodeHeartbeat(ctx)
|
||||||
|
|
||||||
// initial peer info update
|
// initial peer info update
|
||||||
if err := s.updatePeerInfo(ctx); err != nil {
|
if err := s.updatePeerInfo(ctx, s.cfg.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +265,7 @@ func (s *Server) getOrCreateKeyPair(ctx context.Context, id string) (*v1.KeyPair
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
logrus.Debugf("generating new keypair for %s", s.cfg.ID)
|
logrus.Debugf("generating new keypair for %s", s.cfg.ID)
|
||||||
privateKey, publicKey, err := generateWireguardKeys(ctx)
|
privateKey, publicKey, err := wg.GenerateWireguardKeys(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -315,6 +318,14 @@ func (s *Server) getClusterKey(ctx context.Context) (string, error) {
|
||||||
return redis.String(s.local(ctx, "GET", clusterKey))
|
return redis.String(s.local(ctx, "GET", clusterKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) getWireguardConfigPath() string {
|
||||||
|
return filepath.Join(wireguardConfigDir, s.cfg.InterfaceName+".conf")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) getTunnelName() string {
|
||||||
|
return s.cfg.InterfaceName
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) local(ctx context.Context, cmd string, args ...interface{}) (interface{}, error) {
|
func (s *Server) local(ctx context.Context, cmd string, args ...interface{}) (interface{}, error) {
|
||||||
return s.do(ctx, s.rpool, cmd, args...)
|
return s.do(ctx, s.rpool, cmd, args...)
|
||||||
}
|
}
|
||||||
|
|
27
utils.go
27
utils.go
|
@ -22,7 +22,11 @@
|
||||||
package heimdall
|
package heimdall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -96,3 +100,26 @@ func getInterfaceIP(iface net.Interface) string {
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HashData returns a sha256 sum of the specified data
|
||||||
|
func HashData(data []byte) string {
|
||||||
|
h := sha256.New()
|
||||||
|
h.Write(data)
|
||||||
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HashConfig returns the sha256 hash of the specified path
|
||||||
|
func HashConfig(cfgPath string) (string, error) {
|
||||||
|
if _, err := os.Stat(cfgPath); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
peerData, err := ioutil.ReadFile(cfgPath)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return HashData(peerData), nil
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package server
|
package wg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -38,8 +38,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultWireguardInterface = "darknet"
|
wireguardNodeTemplate = `# managed by heimdall
|
||||||
wireguardTemplate = `# managed by heimdall
|
|
||||||
[Interface]
|
[Interface]
|
||||||
PrivateKey = {{ .PrivateKey }}
|
PrivateKey = {{ .PrivateKey }}
|
||||||
ListenPort = {{ .ListenPort }}
|
ListenPort = {{ .ListenPort }}
|
||||||
|
@ -47,39 +46,56 @@ Address = {{ .Address }}
|
||||||
PostUp = iptables -A FORWARD -i {{ .Iface }} -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i {{ .Iface }} -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
PostUp = iptables -A FORWARD -i {{ .Iface }} -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i {{ .Iface }} -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||||
PostDown = iptables -D FORWARD -i {{ .Iface }} -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i {{ .Iface }} -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
PostDown = iptables -D FORWARD -i {{ .Iface }} -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i {{ .Iface }} -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
||||||
{{ range .Peers }}
|
{{ range .Peers }}
|
||||||
|
# {{ .ID }}
|
||||||
[Peer]
|
[Peer]
|
||||||
PublicKey = {{ .KeyPair.PublicKey }}
|
PublicKey = {{ .KeyPair.PublicKey }}
|
||||||
{{ if .AllowedIPs }}AllowedIPs = {{ allowedIPs .AllowedIPs }}{{ end }}
|
{{ if .AllowedIPs }}AllowedIPs = {{ csvList .AllowedIPs }}{{ end }}{{ if ne .Endpoint "" }}
|
||||||
Endpoint = {{ .Endpoint }}
|
Endpoint = {{ .Endpoint }}{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
`
|
||||||
|
wireguardPeerTemplate = `# managed by heimdall
|
||||||
|
[Interface]
|
||||||
|
PrivateKey = {{ .PrivateKey }}
|
||||||
|
Address = {{ .Address }}
|
||||||
|
DNS = {{ csvList .DNS }}
|
||||||
|
{{ range .Peers }}
|
||||||
|
# {{ .ID }}
|
||||||
|
[Peer]
|
||||||
|
PublicKey = {{ .KeyPair.PublicKey }}
|
||||||
|
{{ if .AllowedIPs }}AllowedIPs = {{ csvList .AllowedIPs }}{{ end }}{{ if ne .Endpoint "" }}
|
||||||
|
Endpoint = {{ .Endpoint }}{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
func allowedIPs(s []string) string {
|
func csvList(s []string) string {
|
||||||
return strings.Join(s, ", ")
|
return strings.Join(s, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
type wireguardConfig struct {
|
// Config is the Wireguard configuration
|
||||||
|
type Config struct {
|
||||||
Iface string
|
Iface string
|
||||||
PrivateKey string
|
PrivateKey string
|
||||||
ListenPort int
|
ListenPort int
|
||||||
Address string
|
Address string
|
||||||
Peers []*v1.Peer
|
Peers []*v1.Peer
|
||||||
|
DNS []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateNodeWireguardConfig(cfg *wireguardConfig) (string, error) {
|
// GenerateNodeConfig generates the configuration for a node (server)
|
||||||
|
func GenerateNodeConfig(cfg *Config, cfgPath string) (string, error) {
|
||||||
f, err := ioutil.TempFile("", "heimdall-wireguard-")
|
f, err := ioutil.TempFile("", "heimdall-wireguard-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
t, err := template.New("wireguard").Funcs(template.FuncMap{
|
t, err := template.New("wireguard-node").Funcs(template.FuncMap{
|
||||||
"allowedIPs": allowedIPs,
|
"csvList": csvList,
|
||||||
}).Parse(wireguardTemplate)
|
}).Parse(wireguardNodeTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(filepath.Dir(wireguardConfigPath), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(cfgPath), 0755); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +107,33 @@ func generateNodeWireguardConfig(cfg *wireguardConfig) (string, error) {
|
||||||
return f.Name(), nil
|
return f.Name(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateWireguardKeys(ctx context.Context) (string, string, error) {
|
// GeneratePeerConfig generates the configuration for a peer
|
||||||
|
func GeneratePeerConfig(cfg *Config, cfgPath string) (string, error) {
|
||||||
|
f, err := ioutil.TempFile("", "heimdall-wireguard-")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
t, err := template.New("wireguard-peer").Funcs(template.FuncMap{
|
||||||
|
"csvList": csvList,
|
||||||
|
}).Parse(wireguardPeerTemplate)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(filepath.Dir(cfgPath), 0755); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := t.Execute(f, cfg); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
f.Close()
|
||||||
|
|
||||||
|
return f.Name(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenerateWireguardKeys generates a new private/public Wireguard keypair
|
||||||
|
func GenerateWireguardKeys(ctx context.Context) (string, string, error) {
|
||||||
kData, err := wg(ctx, nil, "genkey")
|
kData, err := wg(ctx, nil, "genkey")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
|
@ -107,25 +149,21 @@ func generateWireguardKeys(ctx context.Context) (string, string, error) {
|
||||||
return privateKey, publicKey, nil
|
return privateKey, publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTunnelName() string {
|
// RestartTunnel restarts the named tunnel
|
||||||
return strings.Replace(filepath.Base(wireguardConfigPath), filepath.Ext(filepath.Base(wireguardConfigPath)), "", 1)
|
func RestartTunnel(ctx context.Context, name string) error {
|
||||||
}
|
logrus.Infof("restarting tunnel %s", name)
|
||||||
|
|
||||||
func restartWireguardTunnel(ctx context.Context) error {
|
|
||||||
tunnelName := getTunnelName()
|
|
||||||
logrus.Infof("restarting tunnel %s", tunnelName)
|
|
||||||
d, err := wg(ctx, nil)
|
d, err := wg(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// only stop if running
|
// only stop if running
|
||||||
if string(d) != "" {
|
if string(d) != "" {
|
||||||
d, err := wgquick(ctx, "down", tunnelName)
|
d, err := wgquick(ctx, "down", name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, string(d))
|
return errors.Wrap(err, string(d))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
u, err := wgquick(ctx, "up", tunnelName)
|
u, err := wgquick(ctx, "up", name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, string(u))
|
return errors.Wrap(err, string(u))
|
||||||
}
|
}
|
Loading…
Reference in a new issue