• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂658 (tree)
時間2015-03-14 18:59:39
作者ornse01

Log Message

enable to specify IP address string for host argument.

Change Summary

差異

--- bchanf/trunk/src/http/http_connector.c (revision 657)
+++ bchanf/trunk/src/http/http_connector.c (revision 658)
@@ -1,7 +1,7 @@
11 /*
22 * http_connector.c
33 *
4- * Copyright (c) 2012-2014 project bchan
4+ * Copyright (c) 2012-2015 project bchan
55 *
66 * This software is provided 'as-is', without any express or implied
77 * warranty. In no event will the authors be held liable for any damages
@@ -129,6 +129,7 @@
129129 W err;
130130 B buf[HBUFLEN];
131131 HOSTENT ent;
132+ struct in_addr addr;
132133 struct sockaddr_in *addr_in;
133134
134135 entry->host = malloc(sizeof(UB)*(host_len+1));
@@ -140,14 +141,18 @@
140141 entry->host[host_len] = '\0';
141142 entry->host_len = host_len;
142143
143- err = so_gethostbyname(entry->host, &ent, buf);
144- if (err < 0) {
145- goto error_gethostbyname;
144+ err = inet_aton(host, &addr);
145+ if (err == 0) {
146+ err = so_gethostbyname(entry->host, &ent, buf);
147+ if (err < 0) {
148+ goto error_gethostbyname;
149+ }
150+ addr.s_addr = *(unsigned int *)(ent.h_addr_list[0]);
146151 }
147152 addr_in = (struct sockaddr_in *)&(entry->addr);
148153 addr_in->sin_family = AF_INET;
149154 addr_in->sin_port = htons( port );
150- addr_in->sin_addr.s_addr = *(unsigned int *)(ent.h_addr_list[0]);
155+ addr_in->sin_addr = addr;
151156
152157 entry->aborted_by_user = False;
153158 entry->status = WAITING_TRANSPORT;
Show on old repository browser