aboutsummaryrefslogtreecommitdiff
path: root/test_msgnet_tls
diff options
context:
space:
mode:
Diffstat (limited to 'test_msgnet_tls')
-rw-r--r--test_msgnet_tls/alice.pem83
-rw-r--r--test_msgnet_tls/bob.pem83
-rw-r--r--test_msgnet_tls/main.go171
3 files changed, 337 insertions, 0 deletions
diff --git a/test_msgnet_tls/alice.pem b/test_msgnet_tls/alice.pem
new file mode 100644
index 0000000..6efe00f
--- /dev/null
+++ b/test_msgnet_tls/alice.pem
@@ -0,0 +1,83 @@
+-----BEGIN PRIVATE KEY-----
+MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDZFKh7iaGPvfvh
+6qYrQN0Twq9nnpukjHYG+Zjuq/6T/JgMVezRXDA6e6nPH1va6tRzi+MsJ4Ues7al
+m6ddnxNgUOI2ROl9G6Gmx68Y75BGR1vKMUw7ujz8flaXYFO5mASSbE87pI5F/Hm/
+7k0Ke47rEE6Ke1iARcv0pW9loFT8y00NBXg/IQSUSb1riDXOHVK3fY8xHN5w5/pX
+waLNpqTByKOPcBCQhJBWh83n09vYysDEFzJC3QUvNWNCUttbgexqY8hJO4jP5SD+
+DmSiPw+6gNiyJdPdvmY+VgDXtd1d1ApihkiLlSa3EhQAMbS6ajM3NuwS5ikpnZ5c
+NDvGuBS4XQx8R+X93Q1xyeclNVkd2bFj0rdjfIxyurl8Nziq2/NM/AVCtBXCdGDO
+8aFnivPlA/FtfKbfuhhNVWts0ODLHR8dd5AZpGjtgZBJiXW97XQOeG0hDp8WwBNn
+s0UFEewkMOMX1ByA7ZWeOSiJHe+lcmVEs7RaUcEhs5OK/sgAo3Ig+4mO0z6VH8gp
+/WxP8ce+5xA6cTao2wJn3N1ux4Oq4fqZXR3rPh7IcEkHCyBKL1jxiUmPlIXvmED2
+PzyWSxyoDTm9w1TBLamD0Usdd1P99Rclgri3erhr6kT4YnWV0WMqrsP3ZserGTkm
+3Gsi6s6X9sTdu3Yi/P4N2nvRPZOB0wIDAQABAo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
+d6qBH3eG2paTc+aVRIaJhhwR/ommpILiU8X/kXq6StLGB1YD5Jm0KvREyME/o0U7
+sT/91lpmMtRtwqaIOTZbUn1vEmS3aHZKS5q+Vs/eYZm3exF/L+Bzy40vn9wxU0I=
+-----END CERTIFICATE-----
diff --git a/test_msgnet_tls/bob.pem b/test_msgnet_tls/bob.pem
new file mode 100644
index 0000000..8f8afcc
--- /dev/null
+++ b/test_msgnet_tls/bob.pem
@@ -0,0 +1,83 @@
+-----BEGIN PRIVATE KEY-----
+MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDfnQZzGUUL/pQN
+4g3U7fI6DHsvy6AztawB89m5nbXOFA9YGiFpzTGByZ6xAJRRnoz5HtbwjbkAYiUc
+G+sbGF7RSDAchAOC0EYKK8YQd/kGYzD/mIFzyzRSk1Kpc/SSIDKmuO9iFWfNSOqI
+zfkE8M0hV2vwbZ/tZfi/ToP8nH7Zllpa6E2SQhQRDsojMPSyMkP2uYvBL9CjRbZz
+gsVPaHItfQkP5c3+oNTgTNbv6HwI98h2xXYIAL8MKg7B/xj8BXczf9KGhWNCcRn/
+ci+wME08e9+FZUH1JYIQgRAu1Q7eGp5JhGl4Tls9/YTH7FFVTbpZZaoRj95mMKVT
+zrXOlSdiQcAuAnfKvSm733tK9VL/JFFWfrscWaWONKUEogW988hQ7xg+0VQ5BBd3
+/S6yT/0fUjVLwM2hoJguQFtNkuBdeT7Bp+cVO0uI+g1sPFV3+0XC0Z5MytwedS+0
+BSq3KBheQ/FBTDZ8wHk9H1fPbNX4va1dj4bw2D5vuQL1gYTSIV5yUARakt78qH9s
+9+gkUfJGjtiI8FBbF5p4AhbBpKD0dhy7Pbkzw3zaWGCxOATUXTxiB9qgLwjancax
+x1XegMB8ZhjoNjUzX1iBh11Sejmqv0Sv1PLdAgzxlIVfaIkf/wyQwX/GGbqN7ne/
+J+lk2DIe3ynxn6FmIdvtfrFbbCGpxQIDAQABAoICAQCvAlp14qUjig+d/foN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p/pCEV7aqHI0Ds9VYy82IJAT
+070s/gtoLj5DussTetb9rh7Nt9ndJ5T7vvL9aeSmulRs2Z1j6u7rTvo4TjAbLbxx
+bCR8r/T+5G0F9qLC6o4C2kFfZSiogxtM8n6tCJzzpWnpMwVad0a+GuH4tdNFsQA=
+-----END CERTIFICATE-----
diff --git a/test_msgnet_tls/main.go b/test_msgnet_tls/main.go
new file mode 100644
index 0000000..c45cfdf
--- /dev/null
+++ b/test_msgnet_tls/main.go
@@ -0,0 +1,171 @@
+package main
+
+// #cgo CFLAGS: -I${SRCDIR}/../salticidae/include/
+// #include <stdlib.h>
+// #include "salticidae/network.h"
+// void onTerm(int sig, void *);
+// void onReceiveHello(msg_t *, msgnetwork_conn_t *, void *);
+// void onReceiveAck(msg_t *, msgnetwork_conn_t *, void *);
+// bool connHandler(msgnetwork_conn_t *, bool, void *);
+// void errorHandler(SalticidaeCError *, bool, void *);
+import "C"
+
+import (
+ "encoding/binary"
+ "os"
+ "fmt"
+ "unsafe"
+ "github.com/Determinant/salticidae-go"
+)
+
+const (
+ MSG_OPCODE_HELLO salticidae.Opcode = iota
+ MSG_OPCODE_ACK
+)
+
+func msgHelloSerialize(name string, text string) salticidae.Msg {
+ serialized := salticidae.NewDataStream()
+ t := make([]byte, 4)
+ binary.LittleEndian.PutUint32(t, uint32(len(name)))
+ serialized.PutData(t)
+ serialized.PutData([]byte(name))
+ serialized.PutData([]byte(text))
+ return salticidae.NewMsgMovedFromByteArray(
+ MSG_OPCODE_HELLO, salticidae.NewByteArrayMovedFromDataStream(serialized))
+}
+
+func msgHelloUnserialize(msg salticidae.Msg) (name string, text string) {
+ p := msg.GetPayloadByMove()
+ t := p.GetDataInPlace(4); length := binary.LittleEndian.Uint32(t.Get()); t.Release()
+ t = p.GetDataInPlace(int(length)); name = string(t.Get()); t.Release()
+ t = p.GetDataInPlace(p.Size()); text = string(t.Get()); t.Release()
+ return
+}
+
+func msgAckSerialize() salticidae.Msg {
+ return salticidae.NewMsgMovedFromByteArray(MSG_OPCODE_ACK, salticidae.NewByteArray())
+}
+
+func checkError(err *salticidae.Error) {
+ if err.GetCode() != 0 {
+ fmt.Printf("error during a sync call: %s\n", salticidae.StrError(err.GetCode()))
+ os.Exit(1)
+ }
+}
+
+type MyNet struct {
+ net salticidae.MsgNetwork
+ name string
+ peerCert salticidae.UInt256
+ cname *C.char
+}
+
+var (
+ alice, bob MyNet
+ ec salticidae.EventContext
+)
+
+//export onTerm
+func onTerm(_ C.int, _ unsafe.Pointer) {
+ ec.Stop()
+}
+
+//export onReceiveHello
+func onReceiveHello(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, userdata unsafe.Pointer) {
+ msg := salticidae.MsgFromC(salticidae.CMsg(_msg))
+ conn := salticidae.MsgNetworkConnFromC(salticidae.CMsgNetworkConn(_conn))
+ net := conn.GetNet()
+ name, text := msgHelloUnserialize(msg)
+ myName := C.GoString((*C.char)(userdata))
+ fmt.Printf("[%s] %s says %s\n", myName, name, text)
+ ack := msgAckSerialize()
+ net.SendMsg(ack, conn)
+}
+
+//export onReceiveAck
+func onReceiveAck(_ *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, userdata unsafe.Pointer) {
+ myName := C.GoString((*C.char)(userdata))
+ fmt.Printf("[%s] the peer knows\n", myName)
+}
+
+//export connHandler
+func connHandler(_conn *C.struct_msgnetwork_conn_t, connected C.bool, userdata unsafe.Pointer) C.bool {
+ conn := salticidae.MsgNetworkConnFromC(salticidae.CMsgNetworkConn(_conn))
+ net := conn.GetNet()
+ myName := C.GoString((*C.char)(userdata))
+ n := alice
+ if myName == "bob" { n = bob }
+ res := true
+ if connected {
+ certHash := conn.GetPeerCert().GetDer().GetHash()
+ res = certHash.IsEq(n.peerCert)
+ if conn.GetMode() == salticidae.CONN_MODE_ACTIVE {
+ fmt.Printf("[%s] Connected, sending hello.\n", myName)
+ hello := msgHelloSerialize(myName, "Hello there!")
+ n.net.SendMsg(hello, conn)
+ } else {
+ status := "fail"
+ if res { status = "ok" }
+ fmt.Printf("[%s] Accepted, waiting for greetings.\n" +
+ "The peer certificate footprint is %s (%s)\n",
+ myName, certHash.GetHex(), status)
+ }
+ } else {
+ fmt.Printf("[%s] Disconnected, retrying.\n", myName)
+ err := salticidae.NewError()
+ net.Connect(conn.GetAddr(), false, &err)
+ }
+ return C.bool(res)
+}
+
+//export errorHandler
+func errorHandler(_err *C.struct_SalticidaeCError, fatal C.bool, _ unsafe.Pointer) {
+ err := (*salticidae.Error)(unsafe.Pointer(_err))
+ s := "recoverable"
+ if fatal { s = "fatal" }
+ fmt.Printf("Captured %s error during an async call: %s\n", s, salticidae.StrError(err.GetCode()))
+}
+
+func genMyNet(ec salticidae.EventContext,
+ name string, peerCert string,
+ myAddr salticidae.NetAddr, otherAddr salticidae.NetAddr) MyNet {
+ err := salticidae.NewError()
+ netconfig := salticidae.NewMsgNetworkConfig()
+ netconfig.EnableTLS(true)
+ netconfig.TLSKeyFile(name + ".pem")
+ netconfig.TLSCertFile(name + ".pem")
+ net := salticidae.NewMsgNetwork(ec, netconfig, &err); checkError(&err)
+ _peerCert := salticidae.NewUInt256FromByteArray(salticidae.NewByteArrayFromHex(peerCert))
+ cname := C.CString(name)
+ n := MyNet { net: net, name: name, peerCert: _peerCert, cname: cname }
+ n.net.RegHandler(MSG_OPCODE_HELLO, salticidae.MsgNetworkMsgCallback(C.onReceiveHello), unsafe.Pointer(cname))
+ n.net.RegHandler(MSG_OPCODE_ACK, salticidae.MsgNetworkMsgCallback(C.onReceiveAck), unsafe.Pointer(cname))
+ n.net.RegConnHandler(salticidae.MsgNetworkConnCallback(C.connHandler), unsafe.Pointer(cname))
+ n.net.RegErrorHandler(salticidae.MsgNetworkErrorCallback(C.errorHandler), unsafe.Pointer(cname))
+
+ n.net.Start()
+ n.net.Listen(myAddr, &err); checkError(&err)
+ n.net.Connect(otherAddr, false, &err); checkError(&err)
+ return n
+}
+
+func main() {
+ ec = salticidae.NewEventContext()
+
+ aliceAddr := salticidae.NewAddrFromIPPortString("127.0.0.1:12345")
+ bobAddr := salticidae.NewAddrFromIPPortString("127.0.0.1:12346")
+
+ alice = genMyNet(ec, "alice", "ed5a9a8c7429dcb235a88244bc69d43d16b35008ce49736b27aaa3042a674043", aliceAddr, bobAddr)
+ bob = genMyNet(ec, "bob", "ef3bea4e72f4d0e85da7643545312e2ff6dded5e176560bdffb1e53b1cef4896", bobAddr, aliceAddr)
+
+ ev_int := salticidae.NewSigEvent(ec, salticidae.SigEventCallback(C.onTerm), nil)
+ ev_int.Add(salticidae.SIGINT)
+ ev_term := salticidae.NewSigEvent(ec, salticidae.SigEventCallback(C.onTerm), nil)
+ ev_term.Add(salticidae.SIGTERM)
+
+ ec.Dispatch()
+ alice.net.Stop()
+ bob.net.Stop()
+ C.free(unsafe.Pointer(alice.cname))
+ C.free(unsafe.Pointer(bob.cname))
+}