This include Disobedience. IPv6 works at least to loopback...
if(password)
config->password = password;
if(local)
if(password)
config->password = password;
if(local)
+ config->connect.af = -1;
n = optind;
optind = 1; /* for subsequent getopt calls */
/* gcrypt initialization */
n = optind;
optind = 1; /* for subsequent getopt calls */
/* gcrypt initialization */
if(config->password)
return;
/* If we already have a host and/or port that's good too */
if(config->password)
return;
/* If we already have a host and/or port that's good too */
+ if(config->connect.af != -1)
return;
/* If there's a suitable socket that's probably what we wanted */
const char *s = config_get_file("socket");
return;
/* If there's a suitable socket that's probably what we wanted */
const char *s = config_get_file("socket");
}
static const char *get_hostname(void) {
}
static const char *get_hostname(void) {
- return config->connect.n >= 2 ? config->connect.s[0] : "";
+ if(config->connect.af == -1 || !config->connect.address)
+ return "";
+ else
+ return config->connect.address;
}
static const char *get_service(void) {
}
static const char *get_service(void) {
- return config->connect.n >= 2 ? config->connect.s[1] : "";
+ if(config->connect.af == -1)
+ return "";
+ else {
+ char *s;
+
+ byte_xasprintf(&s, "%d", config->connect.port);
+ return s;
+ }
}
static const char *get_username(void) {
}
static const char *get_username(void) {
}
static void set_hostname(struct config *c, const char *s) {
}
static void set_hostname(struct config *c, const char *s) {
- c->connect.s[0] = (char *)s;
+ if(c->connect.af == -1)
+ c->connect.af = AF_UNSPEC;
+ c->connect.address = xstrdup(s);
}
static void set_service(struct config *c, const char *s) {
}
static void set_service(struct config *c, const char *s) {
- c->connect.s[1] = (char *)s;
+ c->connect.port = atoi(s);
}
static void set_username(struct config *c, const char *s) {
}
static void set_username(struct config *c, const char *s) {
size_t n;
const gboolean remote = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lwi_remote));
size_t n;
const gboolean remote = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lwi_remote));
- if(remote) {
- c->connect.n = 2;
- c->connect.s = xcalloc(2, sizeof (char *));
- } else {
- c->connect.n = 0;
- c->connect.s = 0;
- }
+ if(remote)
+ c->connect.af = AF_UNSPEC;
+ else
+ c->connect.af = -1;
for(n = 0; n < NLWIS; ++n)
if(remote || !(lwis[n].flags & LWI_REMOTE))
lwis[n].set(c, xstrdup(gtk_entry_get_text(GTK_ENTRY(lwi_entry[n]))));
for(n = 0; n < NLWIS; ++n)
if(remote || !(lwis[n].flags & LWI_REMOTE))
lwis[n].set(c, xstrdup(gtk_entry_get_text(GTK_ENTRY(lwi_entry[n]))));
"password %s\n",
quoteutf8(config->username),
quoteutf8(config->password));
"password %s\n",
quoteutf8(config->username),
quoteutf8(config->password));
- if(rc >= 0 && config->connect.n)
- rc = fprintf(fp, "connect %s %s\n",
- quoteutf8(config->connect.s[0]),
- quoteutf8(config->connect.s[1]));
+ if(rc >= 0 && config->connect.af != -1) {
+ char **vec;
+
+ netaddress_format(&config->connect, NULL, &vec);
+ rc = fprintf(fp, "connect %s %s %s\n", vec[0], vec[1], vec[2]);
+ }
if(rc < 0) {
fpopup_msg(GTK_MESSAGE_ERROR, "error writing to %s: %s",
tmp, strerror(errno));
if(rc < 0) {
fpopup_msg(GTK_MESSAGE_ERROR, "error writing to %s: %s",
tmp, strerror(errno));
}
/* Initial settings */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lwi_remote),
}
/* Initial settings */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lwi_remote),
- config->connect.n >= 2);
+ config->connect.af != -1);
lwi_remote_toggled(GTK_TOGGLE_BUTTON(lwi_remote), 0);
buttonbox = create_buttons(buttons, NBUTTONS);
vbox = gtk_vbox_new(FALSE, 1);
lwi_remote_toggled(GTK_TOGGLE_BUTTON(lwi_remote), 0);
buttonbox = create_buttons(buttons, NBUTTONS);
vbox = gtk_vbox_new(FALSE, 1);
struct addrinfo *res = 0;
char *name;
socklen_t len;
struct addrinfo *res = 0;
char *name;
socklen_t len;
-
- static const struct addrinfo pref = {
- .ai_flags = 0,
- .ai_family = PF_INET,
- .ai_socktype = SOCK_STREAM,
- .ai_protocol = IPPROTO_TCP,
- };
- if(c->connect.n) {
- res = get_address(&c->connect, &pref, &name);
- if(!res) return -1;
+ if(c->connect.af != -1) {
+ res = netaddress_resolve(&c->connect, 0, IPPROTO_TCP);
+ if(!res)
+ return -1;
sa = res->ai_addr;
len = res->ai_addrlen;
} else {
sa = res->ai_addr;
len = res->ai_addrlen;
} else {
*sap = xmalloc_noptr(len);
memcpy(*sap, sa, len);
if(namep)
*sap = xmalloc_noptr(len);
memcpy(*sap, sa, len);
if(namep)
+ *namep = format_sockaddr(sa);
if(res)
freeaddrinfo(res);
return len;
if(res)
freeaddrinfo(res);
return len;
-static int validate_addrport(const struct config_state attribute((unused)) *cs,
- int nvec,
- char attribute((unused)) **vec) {
- switch(nvec) {
- case 0:
- error(0, "%s:%d: missing address",
- cs->path, cs->line);
- return -1;
- case 1:
- error(0, "%s:%d: missing port name/number",
- cs->path, cs->line);
- return -1;
- case 2:
- return 0;
- default:
- error(0, "%s:%d: expected ADDRESS PORT",
- cs->path, cs->line);
- return -1;
- }
-}
-
static int validate_algo(const struct config_state attribute((unused)) *cs,
int nvec,
char **vec) {
static int validate_algo(const struct config_state attribute((unused)) *cs,
int nvec,
char **vec) {
{ C(checkpoint_kbyte), &type_integer, validate_non_negative },
{ C(checkpoint_min), &type_integer, validate_non_negative },
{ C(collection), &type_collections, validate_any },
{ C(checkpoint_kbyte), &type_integer, validate_non_negative },
{ C(checkpoint_min), &type_integer, validate_non_negative },
{ C(collection), &type_collections, validate_any },
- { C(connect), &type_stringlist, validate_addrport },
+ { C(connect), &type_netaddress, validate_destaddr },
{ C(cookie_login_lifetime), &type_integer, validate_positive },
{ C(cookie_key_lifetime), &type_integer, validate_positive },
{ C(dbversion), &type_integer, validate_positive },
{ C(cookie_login_lifetime), &type_integer, validate_positive },
{ C(cookie_key_lifetime), &type_integer, validate_positive },
{ C(dbversion), &type_integer, validate_positive },
c->broadcast.af = -1;
c->broadcast_from.af = -1;
c->listen.af = -1;
c->broadcast.af = -1;
c->broadcast_from.af = -1;
c->listen.af = -1;
const char *password;
/** @brief Address to connect to */
const char *password;
/** @brief Address to connect to */
- struct stringlist connect;
+ struct netaddress connect;
/** @brief Directories to search for web templates */
struct stringlist templates;
/** @brief Directories to search for web templates */
struct stringlist templates;