electrumc.cView |
---|
93 | 93 … | host = argv[1]; |
94 | 94 … | method = argv[2]; |
95 | 95 … | params = argc == 3 ? NULL : argv[3]; |
96 | 96 … | |
97 | | - port = strchr(host, ':'); |
98 | | - if (!port) errx(1, "address should be in format <host>:<port>:<type>"); |
99 | | - *port++ = '\0'; |
100 | | - type = strchr(port, ':'); |
101 | | - if (!type) errx(1, "address type missing"); |
| 97 … | + type = strrchr(host, ':'); |
| 98 … | + if (!type) errx(1, "address should be in format <host>:<port>:<type>"); |
102 | 99 … | *type++ = '\0'; |
103 | | - |
104 | 100 … | if (!strcmp(type, "t")) use_ssl = false; |
105 | 101 … | else if (!strcmp(type, "s")) use_ssl = true; |
106 | | - else errx(1, "address type must be 't' or 's'"); |
| 102 … | + else errx(1, "address type must be 't' or 's', but found: '%s'", type); |
107 | 103 … | |
| 104 … | + port = strrchr(host, ':'); |
| 105 … | + if (!port) errx(1, "address should be in format <host>:<port>:<type>"); |
| 106 … | + *port++ = '\0'; |
| 107 … | + |
| 108 … | + if (!*host) errx(1, "address hostname missing"); |
| 109 … | + |
108 | 110 … | if (use_ssl) { |
109 | 111 … | ssl_ctx = SSL_CTX_new(TLS_client_method()); |
110 | 112 … | if (ssl_ctx == NULL) errx(1, "failed to create ssl context"); |
111 | 113 … | (void)SSL_CTX_set_mode(ssl_ctx, SSL_MODE_AUTO_RETRY); |