// NewPoint returns a new Point server based on given configuration. // The server is not started at this point. func NewPoint(pConfig config.PointConfig) (*Point, error) { var vpoint = new(Point) vpoint.port = pConfig.Port() ichFactory := proxy.GetInboundConnectionHandlerFactory(pConfig.InboundConfig().Protocol()) if ichFactory == nil { log.Error("Unknown inbound connection handler factory %s", pConfig.InboundConfig().Protocol()) return nil, config.BadConfiguration } ichConfig := pConfig.InboundConfig().Settings(config.TypeInbound) ich, err := ichFactory.Create(vpoint, ichConfig) if err != nil { log.Error("Failed to create inbound connection handler: %v", err) return nil, err } vpoint.ich = ich ochFactory := proxy.GetOutboundConnectionHandlerFactory(pConfig.OutboundConfig().Protocol()) if ochFactory == nil { log.Error("Unknown outbound connection handler factory %s", pConfig.OutboundConfig().Protocol()) return nil, config.BadConfiguration } ochConfig := pConfig.OutboundConfig().Settings(config.TypeOutbound) och, err := ochFactory.Create(ochConfig) if err != nil { log.Error("Failed to create outbound connection handler: %v", err) return nil, err } vpoint.och = och return vpoint, nil }
// NewPoint returns a new Point server based on given configuration. // The server is not started at this point. func NewPoint(pConfig config.PointConfig) (*Point, error) { var vpoint = new(Point) vpoint.port = pConfig.Port() ichFactory, ok := inboundFactories[pConfig.InboundConfig().Protocol()] if !ok { log.Error("Unknown inbound connection handler factory %s", pConfig.InboundConfig().Protocol()) return nil, errors.NewBadConfigurationError() } ichConfig := pConfig.InboundConfig().Settings(config.TypeInbound) ich, err := ichFactory.Create(vpoint, ichConfig) if err != nil { log.Error("Failed to create inbound connection handler: %v", err) return nil, err } vpoint.ich = ich ochFactory, ok := outboundFactories[pConfig.OutboundConfig().Protocol()] if !ok { log.Error("Unknown outbound connection handler factory %s", pConfig.OutboundConfig().Protocol()) return nil, errors.NewBadConfigurationError() } ochConfig := pConfig.OutboundConfig().Settings(config.TypeOutbound) och, err := ochFactory.Create(vpoint, ochConfig) if err != nil { log.Error("Failed to create outbound connection handler: %v", err) return nil, err } vpoint.och = och return vpoint, nil }