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

fix: support port-only connection #122

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

tamil-rss
Copy link
Contributor

@tamil-rss tamil-rss commented May 23, 2024

Current version doesn't support port only connection (expecting host option) by default.

The _initSocket method has the option to connect using port alone,

client = net.createConnection({ port: this.settings.clamdscan.port, timeout });

if (this.settings.clamdscan.socket)
    client = net.createConnection({ path: this.settings.clamdscan.socket, timeout });
// If a port is specified, we're going to be connecting via TCP
else if (this.settings.clamdscan.port) {
    // If a host is specified (usually for a remote host)
    if (this.settings.clamdscan.host) {
        if (this.settings.clamdscan.tls) {
            client = tls.connect({
                host: this.settings.clamdscan.host,
                port: this.settings.clamdscan.port,
                // Activate SNI
                // servername: this.settings.clamdscan.host,
                timeout,
            });
        } else {
            client = net.createConnection({
                host: this.settings.clamdscan.host,
                port: this.settings.clamdscan.port,
                timeout,
            });
        }
    }
    // Host can be ignored since the default is `localhost`
    else if (this.settings.tls) {
        client = tls.connect({ port: this.settings.clamdscan.port, timeout });
    } else {
        client = net.createConnection({ port: this.settings.clamdscan.port, timeout });
    }
}

But, init method has a validation that restricts to use port-only connection,

 if ( !this.settings.clamdscan.socket && !this.settings.clamdscan.host) {
      const err = new NodeClamError('No valid & active virus scanning binaries are active and available and no socket/host option provided!');
      return hasCb ? cb(err, null) : reject(err);
}

This fix should solve issue #123

@kylefarris kylefarris merged commit 422b726 into kylefarris:master Jul 3, 2024
@kylefarris
Copy link
Owner

Your changes have been added to v2.2.2. Thank you for your contribution!

@kylefarris
Copy link
Owner

Closes #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants