fetch: hardcode HTTPS port and fallback to /etc/services for other unknown ports.

This commit is contained in:
Juan RP 2014-08-25 16:07:47 +02:00
parent bc92b387cb
commit 25e8002737
3 changed files with 8 additions and 2 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.38 (???): xbps-0.38 (???):
* libxbps: the fetch code now is able to connect to HTTPS without the need of
/etc/services being available; We don't expect those ports to change anytime!
* xbps-uchroot(8) is now only built on linux, because it's not portable to other * xbps-uchroot(8) is now only built on linux, because it's not portable to other
Operating Systems. Operating Systems.

View File

@ -201,12 +201,14 @@ fetch_default_port(const char *scheme)
{ {
struct servent *se; struct servent *se;
if ((se = getservbyname(scheme, "tcp")) != NULL)
return (ntohs(se->s_port));
if (strcasecmp(scheme, SCHEME_FTP) == 0) if (strcasecmp(scheme, SCHEME_FTP) == 0)
return (FTP_DEFAULT_PORT); return (FTP_DEFAULT_PORT);
if (strcasecmp(scheme, SCHEME_HTTP) == 0) if (strcasecmp(scheme, SCHEME_HTTP) == 0)
return (HTTP_DEFAULT_PORT); return (HTTP_DEFAULT_PORT);
if (strcasecmp(scheme, SCHEME_HTTPS) == 0)
return (HTTPS_DEFAULT_PORT);
if ((se = getservbyname(scheme, "tcp")) != NULL)
return (ntohs(se->s_port));
return (0); return (0);
} }

View File

@ -34,6 +34,7 @@
#define FTP_DEFAULT_PORT 21 #define FTP_DEFAULT_PORT 21
#define HTTP_DEFAULT_PORT 80 #define HTTP_DEFAULT_PORT 80
#define HTTPS_DEFAULT_PORT 443
#define FTP_DEFAULT_PROXY_PORT 21 #define FTP_DEFAULT_PROXY_PORT 21
#define HTTP_DEFAULT_PROXY_PORT 3128 #define HTTP_DEFAULT_PROXY_PORT 3128