summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-02 18:15:50 -0400
committerJune McEnroe <june@causal.agency>2019-11-02 18:15:50 -0400
commit98f28de10701245053f034e9c386133a39dcb1d9 (patch)
tree40481f37cd4642d9ca6ee43aff83d574090ab9d4
parentFix name of SNI (diff)
downloadpounce-98f28de10701245053f034e9c386133a39dcb1d9.tar.gz
pounce-98f28de10701245053f034e9c386133a39dcb1d9.zip
Send an unrecognized_name alert when failing to dispatch
Diffstat (limited to '')
-rw-r--r--dispatch.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/dispatch.c b/dispatch.c
index 71f8fc7..0c3fffa 100644
--- a/dispatch.c
+++ b/dispatch.c
@@ -133,6 +133,16 @@ static char *serverName(void) {
 	return NULL;
 }
 
+static const uint8_t Alert[] = {
+	0x15, 0x03, 0x03, 0x00, 0x02, // TLSPlaintext
+	0x02, 0x70, // Alert fatal unrecognized_name
+};
+
+static void alert(int sock) {
+	ssize_t len = send(sock, Alert, sizeof(Alert), 0);
+	if (len < 0) warn("send");
+}
+
 int main(int argc, char *argv[]) {
 	const char *host = "localhost";
 	const char *port = "6697";
@@ -268,6 +278,7 @@ int main(int argc, char *argv[]) {
 
 			char *name = serverName();
 			if (!name || name[0] == '.' || name[0] == '/') {
+				alert(event.ptr[i].fd);
 				eventRemove(i);
 				continue;
 			}
@@ -288,11 +299,16 @@ int main(int argc, char *argv[]) {
 #else
 			error = connect(sock, (struct sockaddr *)&addr, SUN_LEN(&addr));
 #endif
-			if (error) warn("%s", name);
 
-			if (!error) {
+			if (error) {
+				warn("%s", name);
+				alert(event.ptr[i].fd);
+			} else {
 				len = sendfd(sock, event.ptr[i].fd);
-				if (len < 0) warn("%s", name);
+				if (len < 0) {
+					warn("%s", name);
+					alert(event.ptr[i].fd);
+				}
 			}
 
 			close(sock);