Esempio n. 1
0
// BuildProxy create new proxy builder
func BuildProxy(proxy Proxy) *ProxyBuilder {
	gStr := gsconfig.String("gsproxy.dhkey.G", "6849211231874234332173554215962568648211715948614349192108760170867674332076420634857278025209099493881977517436387566623834457627945222750416199306671083")

	pStr := gsconfig.String("gsproxy.dhkey.P", "13196520348498300509170571968898643110806720751219744788129636326922565480984492185368038375211941297871289403061486510064429072584259746910423138674192557")

	G, _ := new(big.Int).SetString(gStr, 0)

	P, _ := new(big.Int).SetString(pStr, 0)

	return &ProxyBuilder{

		laddrF: gsconfig.String("gsproxy.frontend.laddr", ":13512"),

		laddrE: gsconfig.String("gsproxy.backend.laddr", ":15827"),

		timeout: gsconfig.Seconds("gsproxy.rpc.timeout", 5),

		dhkeyResolver: handler.DHKeyResolve(func(device *gorpc.Device) (*handler.DHKey, error) {
			return handler.NewDHKey(G, P), nil
		}),

		proxy: proxy,
	}
}
Esempio n. 2
0
}

var stateHandler = handler.NewStateHandler(func(pipeline gorpc.Pipeline, state gorpc.State) {

	pipeline.AddService(MakeRESTfull(1, &_MockRESTful{
		kv: make(map[string]string),
	}))

})

var acceptpor = gorpc.NewAcceptor("test-server",
	gorpc.BuildPipeline(time.Millisecond*10).Handler(
		"dh-server",
		func() gorpc.Handler {
			return handler.NewCryptoServer(handler.DHKeyResolve(func(device *gorpc.Device) (*handler.DHKey, error) {
				return handler.NewDHKey(G, P), nil
			}))
		},
	).Handler(
		"heatbeat-server",
		func() gorpc.Handler {
			return handler.NewHeartbeatHandler(5 * time.Second)
		},
	).Handler(
		"state-handler",

		func() gorpc.Handler {
			return stateHandler
		},
	),
)