support for user agents

This commit is contained in:
Bas van Kervel
2015-08-07 09:56:49 +02:00
parent 2fcf7f1241
commit f9cbd16f27
19 changed files with 363 additions and 90 deletions

View File

@ -48,7 +48,7 @@ func (self *ipcClient) reconnect() error {
return err
}
func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
func startIpc(cfg IpcConfig, codec codec.Codec, initializer func(conn net.Conn) (shared.EthereumApi, error)) error {
os.Remove(cfg.Endpoint) // in case it still exists from a previous run
l, err := net.Listen("unix", cfg.Endpoint)
@ -69,6 +69,13 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
id := newIpcConnId()
glog.V(logger.Debug).Infof("New IPC connection with id %06d started\n", id)
api, err := initializer(conn)
if err != nil {
glog.V(logger.Error).Infof("Unable to initialize IPC connection - %v\n", err)
conn.Close()
continue
}
go handle(id, conn, api, codec)
}