about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bounce.c4
-rw-r--r--bounce.h3
-rw-r--r--client.c10
3 files changed, 6 insertions, 11 deletions
diff --git a/bounce.c b/bounce.c
index 682e2db..8f8d38f 100644
--- a/bounce.c
+++ b/bounce.c
@@ -351,7 +351,7 @@ int main(int argc, char *argv[]) {
 	for (int opt; 0 < (opt = getopt_config(argc, argv, opts, options, NULL));) {
 		switch (opt) {
 			break; case '!': insecure = true;
-			break; case 'A': clientCA = true; caPath = optarg;
+			break; case 'A': caPath = optarg; clientCaps |= CapSASL;
 			break; case 'C': snprintf(certPath, sizeof(certPath), "%s", optarg);
 			break; case 'H': bindHost = optarg;
 			break; case 'K': snprintf(privPath, sizeof(privPath), "%s", optarg);
@@ -360,7 +360,7 @@ int main(int argc, char *argv[]) {
 			break; case 'Q': serverQueueInterval = parseInterval(optarg);
 			break; case 'R': blindReq |= capParse(optarg, NULL);
 			break; case 'S': serverBindHost = optarg;
-			break; case 'T': clientSTS = false;
+			break; case 'T': clientCaps &= ~CapSTS;
 			break; case 'U': snprintf(bindPath, sizeof(bindPath), "%s", optarg);
 			break; case 'W': clientPass = optarg;
 			break; case 'a': blindReq |= CapSASL; plain = optarg;
diff --git a/bounce.h b/bounce.h
index 8a9958f..4aa61b2 100644
--- a/bounce.h
+++ b/bounce.h
@@ -182,8 +182,7 @@ void serverEnqueue(const char *format, ...)
 	__attribute__((format(printf, 1, 2)));
 void serverDequeue(void);
 
-extern bool clientCA;
-extern bool clientSTS;
+extern enum Cap clientCaps;
 extern char *clientPass;
 extern char *clientAway;
 struct Client *clientAlloc(struct tls *tls);
diff --git a/client.c b/client.c
index 4811867..9246085 100644
--- a/client.c
+++ b/client.c
@@ -41,8 +41,7 @@
 
 #include "bounce.h"
 
-bool clientCA;
-bool clientSTS = true;
+enum Cap clientCaps = CapServerTime | CapConsumer | CapPassive | CapSTS;
 char *clientPass;
 char *clientAway;
 
@@ -71,7 +70,7 @@ struct Client *clientAlloc(struct tls *tls) {
 	if (!client) err(EX_OSERR, "calloc");
 	client->tls = tls;
 	client->need = NeedNick | NeedUser | (clientPass ? NeedPass : 0);
-	if (clientCA && tls_peer_cert_provided(tls)) {
+	if ((clientCaps & CapSASL) && tls_peer_cert_provided(tls)) {
 		client->need &= ~NeedPass;
 	}
 	return client;
@@ -179,10 +178,7 @@ static void handlePass(struct Client *client, struct Message *msg) {
 static void handleCap(struct Client *client, struct Message *msg) {
 	if (!msg->params[0]) msg->params[0] = "";
 
-	enum Cap avail = (stateCaps & ~CapSASL)
-		| CapServerTime | CapConsumer | CapPassive
-		| (clientCA ? CapSASL : 0)
-		| (clientSTS ? CapSTS : 0);
+	enum Cap avail = clientCaps | (stateCaps & ~CapSASL);
 	const char *values[CapBits] = {
 		[CapSASLBit] = "EXTERNAL",
 		[CapSTSBit] = "duration=2147483647",