Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MUST have ports defined per session -> CAN have ports defined per se… #522

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/quickfixgo/quickfix/config"
)

//Acceptor accepts connections from FIX clients and manages the associated sessions.
// Acceptor accepts connections from FIX clients and manages the associated sessions.
type Acceptor struct {
app Application
settings *Settings
Expand Down Expand Up @@ -43,7 +43,7 @@ type ConnectionValidator interface {
Validate(netConn net.Conn, session SessionID) error
}

//Start accepting connections.
// Start accepting connections.
func (a *Acceptor) Start() (err error) {
socketAcceptHost := ""
if a.settings.GlobalSettings().HasSetting(config.SocketAcceptHost) {
Expand Down Expand Up @@ -112,7 +112,7 @@ func (a *Acceptor) Start() (err error) {
return
}

//Stop logs out existing sessions, close their connections, and stop accepting new connections.
// Stop logs out existing sessions, close their connections, and stop accepting new connections.
func (a *Acceptor) Stop() {
defer func() {
_ = recover() // suppress sending on closed channel error
Expand Down Expand Up @@ -141,7 +141,7 @@ func (a *Acceptor) RemoteAddr(sessionID SessionID) (net.Addr, bool) {
return val, ok
}

//NewAcceptor creates and initializes a new Acceptor.
// NewAcceptor creates and initializes a new Acceptor.
func NewAcceptor(app Application, storeFactory MessageStoreFactory, settings *Settings, logFactory LogFactory) (a *Acceptor, err error) {
a = &Acceptor{
app: app,
Expand Down Expand Up @@ -290,7 +290,8 @@ func (a *Acceptor) handleConnection(netConn net.Conn) {
}

localConnectionPort := netConn.LocalAddr().(*net.TCPAddr).Port
if expectedPort, ok := a.sessionHostPort[sessID]; !ok || expectedPort != localConnectionPort {
// if we HAVE configured port expectation AND expectation doesn't match - complain
if expectedPort, ok := a.sessionHostPort[sessID]; ok && expectedPort != localConnectionPort {
a.globalLog.OnEventf("Session %v not found for incoming message: %s", sessID, msgBytes)
return
}
Expand Down Expand Up @@ -394,7 +395,8 @@ LOOP:
// Use it when you need a custom authentication logic that includes lower level interactions,
// like mTLS auth or IP whitelistening.
// To remove a previously set validator call it with a nil value:
// a.SetConnectionValidator(nil)
//
// a.SetConnectionValidator(nil)
func (a *Acceptor) SetConnectionValidator(validator ConnectionValidator) {
a.connectionValidator = validator
}