Exemplo n.º 1
0
func initServer2() (api.Transport, api.Transport) {
	if server2 == nil {
		if ramMode {
			// RamNode Mode:
			server2 = ram.New(new(ecc.KeyPair), new(ecc.KeyPair))
		} else {
			// QLDB Mode
			s := qldb.New(new(ecc.KeyPair), new(ecc.KeyPair))
			os.Mkdir("tmp", os.FileMode(int(0755)))
			s.BootstrapDB("tmp/ratnet_test1.ql")
			s.FlushOutbox(0)
			server2 = s
		}

		if udpMode {
			public2 = udp.New(server2)
			admin2 = udp.New(server2)
		} else {
			public2 = https.New("tmp/cert2.pem", "tmp/key2.pem", server2, true)
			admin2 = https.New("tmp/cert2.pem", "tmp/key2.pem", server2, true)
		}
		go serve(public2, admin2, server2, "localhost:30002", "localhost:30202")
		time.Sleep(2 * time.Second)
	}
	return public2, admin2
}
Exemplo n.º 2
0
func initServer1() (api.Transport, api.Transport) {
	if server1 == nil {

		if ramMode {
			// RamNode Mode
			server1 = ram.New(new(ecc.KeyPair), new(ecc.KeyPair))
		} else {
			// QLDB Mode
			s := qldb.New(new(ecc.KeyPair), new(ecc.KeyPair))
			os.Mkdir("tmp", os.FileMode(int(0755)))
			s.BootstrapDB("tmp/ratnet_test1.ql")
			s.FlushOutbox(0)
			server1 = s
		}

		if udpMode {
			public1 = udp.New(server1)
			admin1 = udp.New(server1)
		} else {
			public1 = https.New("tmp/cert1.pem", "tmp/key1.pem", server1, true)
			admin1 = https.New("tmp/cert1.pem", "tmp/key1.pem", server1, true)
		}

		go serve(public1, admin1, server1, "localhost:30001", "localhost:30101")
		time.Sleep(2 * time.Second)
	}
	return public1, admin1
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: awgh/ratnet
func main() {

	var dbFile string
	var publicPort, adminPort int

	flag.StringVar(&dbFile, "dbfile", "ratnet.ql", "QL Database File")
	flag.IntVar(&publicPort, "p", 20001, "HTTPS Public Port (*)")
	flag.IntVar(&adminPort, "ap", 20002, "HTTPS Admin Port (localhost)")
	flag.Parse()

	publicString := fmt.Sprintf(":%d", publicPort)
	adminString := fmt.Sprintf("localhost:%d", adminPort)

	// QLDB Node Mode
	node := qldb.New(new(ecc.KeyPair), new(ecc.KeyPair))
	node.BootstrapDB(dbFile)

	// RamNode Mode:
	//node := ram.New(new(ecc.KeyPair), new(ecc.KeyPair))

	serve(https.New("cert.pem", "key.pem", node, true), https.New("cert.pem", "key.pem", node, true), node, publicString, adminString)
}