summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authormultiplexd2020-02-12 01:02:37 +0000
committerC. McEnroe2020-02-13 00:05:52 +0000
commit1e544ce482ba97f9c4e2be114f88f11e49bdbf1b (patch)
tree5c25157df46e06fe062edb0d91809653b8587c25 /chat.c
parent489df70c37d49ab17b396dcffc6776e2ba7829ed (diff)
Implement source address selection
This commit adds a '-S' command line option and a "bind"
configuration file option to specify the source address to bind to when
connecting to the IRC server.
Diffstat (limited to 'chat.c')
-rw-r--r--chat.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/chat.c b/chat.c
index 2c41d43..c0950fb 100644
--- a/chat.c
+++ b/chat.c
@@ -82,6 +82,7 @@ int main(int argc, char *argv[]) {
 	setlocale(LC_CTYPE, "");
 
 	bool insecure = false;
+	const char *bind = NULL;
 	const char *host = NULL;
 	const char *port = "6697";
 	const char *cert = NULL;
@@ -93,13 +94,14 @@ int main(int argc, char *argv[]) {
 	const char *user = NULL;
 	const char *real = NULL;
 
-	const char *Opts = "!C:H:O:Ra:c:eh:j:k:n:p:r:s:u:vw:";
+	const char *Opts = "!C:H:O:RS:a:c:eh:j:k:n:p:r:s:u:vw:";
 	const struct option LongOpts[] = {
 		{ "insecure", no_argument, NULL, '!' },
 		{ "copy", required_argument, NULL, 'C' },
 		{ "hash", required_argument, NULL, 'H' },
 		{ "open", required_argument, NULL, 'O' },
 		{ "restrict", no_argument, NULL, 'R' },
+		{ "bind", required_argument, NULL, 'S' },
 		{ "sasl-plain", required_argument, NULL, 'a' },
 		{ "cert", required_argument, NULL, 'c' },
 		{ "sasl-external", no_argument, NULL, 'e' },
@@ -124,6 +126,7 @@ int main(int argc, char *argv[]) {
 			break; case 'H': hashInit = strtoul(optarg, NULL, 0);
 			break; case 'O': utilPush(&urlOpenUtil, optarg);
 			break; case 'R': self.restricted = true;
+			break; case 'S': bind = optarg;
 			break; case 'a': sasl = true; self.plain = optarg;
 			break; case 'c': cert = optarg;
 			break; case 'e': sasl = true;
@@ -182,7 +185,7 @@ int main(int argc, char *argv[]) {
 	uiFormat(Network, Cold, NULL, "Traveling...");
 	uiDraw();
 	
-	int irc = ircConnect(host, port);
+	int irc = ircConnect(bind, host, port);
 	if (pass) ircFormat("PASS :%s\r\n", pass);
 	if (sasl) ircFormat("CAP REQ :sasl\r\n");
 	ircFormat("CAP LS\r\n");