Skip to content

Instantly share code, notes, and snippets.

View spikebike's full-sized avatar

Bill Broadley spikebike

View GitHub Profile
@spikebike
spikebike / client.go
Created March 29, 2012 01:13
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@spikebike
spikebike / client output
Created March 29, 2012 03:43 — forked from spikebike/client.go
TLS server and client
$ go run client.go
2012/03/28 22:30:21 client: connected to: 127.0.0.1:8000
Client: Server public key is:
[48 129 159 48 13 6 9 42 134 72 134 247 13 1 1 1 5 0 3 129 141 0 48 129 137 2 129 129 0 188 73 207 11 137 150 106 118 45 27 12 18 76 183 252 31 22 193 109 43 118 130 188 244 197 136 26 55 239 51 225 67 171 20 87 35 107 190 16 158 181 84 225 159 112 70 131 173 136 181 130 151 156 4 142 141 218 100 116 219 228 211 136 155 179 220 50 21 181 134 211 72 22 38 226 51 170 165 39 65 231 3 15 26 54 193 142 242 28 66 96 88 138 237 217 65 144 89 231 177 179 200 116 30 45 148 174 56 57 244 29 17 8 22 86 54 215 14 207 55 223 164 216 184 21 46 29 233 2 3 1 0 1] <nil>
2012/03/28 22:30:21 client: handshake: true
2012/03/28 22:30:21 client: mutual: true
2012/03/28 22:30:21 client: wrote "Hello\n" (6 bytes)
2012/03/28 22:30:21 client: read "Hello\n" (6 bytes)
2012/03/28 22:30:21 client: exiting
$
@spikebike
spikebike / bdr_proto.proto
Created April 18, 2012 01:01
example for protobuf, go, and the repeated protobuf entry
package bdr_proto;
message request {
message blob {
required string sha256 = 1; // the sha256 checksum of the blob
required int32 bsize = 2; // the size of the blob
}
repeated blob blobarray= 1;
}
Wow, everytime I think I'm done. I find another hurdle.
Client and server are identical for my uses. So both client and server
should track the public key of their peers. So Server/Client handshake
can track who I'm talking to, last time I saw them, IP address, and public key.
Now when an RPC call is made I want to use UnaryServerInterceptor and
StreamServerInterceptor to allow every call to check if the Peer has
been tracked, if not look up the public key and set the PeerID.
peerID, ok := ctx.Value(peerIDKey).(int)

Keybase proof

I hereby claim:

  • I am spikebike on github.
  • I am broadley (https://keybase.io/broadley) on keybase.
  • I have a public key whose fingerprint is B02D 3D10 B88A EC20 B774 BE18 C215 0DB0 77E1 EDEA

To claim this, I am signing this object:

[ 0.000000] Machine model: Raspberry Pi 2 Model B
1GB ram version,
root@raspberrypi:~# openssl speed
Doing md4 for 3s on 16 size blocks: 1056069 md4's in 3.00s
Doing md4 for 3s on 64 size blocks: 885899 md4's in 3.00s
Doing md4 for 3s on 256 size blocks: 574828 md4's in 3.00s
Doing md4 for 3s on 1024 size blocks: 237714 md4's in 3.00s
Doing md4 for 3s on 8192 size blocks: 36889 md4's in 3.00s
@spikebike
spikebike / bdr_proto.proto
Created April 18, 2012 01:33 — forked from kylelemons/bdr_proto.proto
example for protobuf, go, and the repeated protobuf entry
package bdr_proto;
message request {
message blob {
required string hash = 1; // the sha256 checksum of the blob
required int32 size = 2; // the size of the blob
}
repeated blob blobs = 1;
}
@spikebike
spikebike / bdr_proto.pb.go
Created April 17, 2012 10:30
Attempt to get go, go-protobuf and repeated records working.
package bdr_proto
import proto "code.google.com/p/goprotobuf/proto"
import "math"
// Reference proto and math imports to suppress error if they are not otherwise used.
var _ = proto.GetString
var _ = math.Inf
type Request struct {
@spikebike
spikebike / add.go
Created April 4, 2012 10:16
Broken TLS + AddService for go-rpcgen
ackage main
import (
"flag"
"log"
"net"
"crypto/rand"
"crypto/tls"
"crypto/x509"
"./addservice"
@spikebike
spikebike / add.go
Created April 4, 2012 10:12
Add service for go-rpcgen
package main
import (
"flag"
"log"
"./addservice"
)
var (