mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[ win64 ] changes for win64 with ssl in docker
This commit is contained in:
parent
b76f48c683
commit
5434b211f0
9
build.sh
9
build.sh
@ -8,7 +8,8 @@ clear
|
|||||||
echo ' --/ \--'
|
echo ' --/ \--'
|
||||||
echo ' --[ Welcome to the elinks build helper ]--'
|
echo ' --[ Welcome to the elinks build helper ]--'
|
||||||
echo ' --[ ]--'
|
echo ' --[ ]--'
|
||||||
echo ' --[ [*] select the architecture 1-4 ]--'
|
echo ' --[ [*] use option 1 to change arch ]--'
|
||||||
|
echo ' --[ [*] use option 4 to config and make ]--'
|
||||||
echo ' --[ [*] use option 5 for config ]--'
|
echo ' --[ [*] use option 5 for config ]--'
|
||||||
echo ' --[ [*] use option 6 for make ]--'
|
echo ' --[ [*] use option 6 for make ]--'
|
||||||
echo ' --[ [*] use option 7 for test ]--'
|
echo ' --[ [*] use option 7 for test ]--'
|
||||||
@ -33,6 +34,7 @@ configure() {
|
|||||||
CC=$1 \
|
CC=$1 \
|
||||||
LD=$2 \
|
LD=$2 \
|
||||||
LDFLAGS=$4 \
|
LDFLAGS=$4 \
|
||||||
|
CFLAGS="-O2 -I/usr/local/include" \
|
||||||
LIBS=$5 \
|
LIBS=$5 \
|
||||||
CXXFLAGS=$6 \
|
CXXFLAGS=$6 \
|
||||||
PKG_CONFIG="./pkg-config.sh" \
|
PKG_CONFIG="./pkg-config.sh" \
|
||||||
@ -43,7 +45,7 @@ configure() {
|
|||||||
--enable-fastmem \
|
--enable-fastmem \
|
||||||
--enable-utf-8 \
|
--enable-utf-8 \
|
||||||
--with-static \
|
--with-static \
|
||||||
--without-openssl \
|
--with-openssl \
|
||||||
--without-quickjs \
|
--without-quickjs \
|
||||||
--disable-88-colors \
|
--disable-88-colors \
|
||||||
--disable-backtrace \
|
--disable-backtrace \
|
||||||
@ -51,6 +53,7 @@ configure() {
|
|||||||
--disable-debug \
|
--disable-debug \
|
||||||
--disable-cgi \
|
--disable-cgi \
|
||||||
--disable-combining \
|
--disable-combining \
|
||||||
|
--disable-gpm \
|
||||||
--disable-gopher \
|
--disable-gopher \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--disable-ipv6 \
|
--disable-ipv6 \
|
||||||
@ -178,7 +181,7 @@ set_arch() {
|
|||||||
MAKE_HOST="x86_64-w64-mingw32"
|
MAKE_HOST="x86_64-w64-mingw32"
|
||||||
BIN_SUFFIX=".exe"
|
BIN_SUFFIX=".exe"
|
||||||
CXXFLAGS="-I/usr/local/include"
|
CXXFLAGS="-I/usr/local/include"
|
||||||
LDFLAGS=""
|
LDFLAGS="-L/usr/local/lib"
|
||||||
LIBS="-lws2_32"
|
LIBS="-lws2_32"
|
||||||
elif [ "$1" = "arm32" ]; then
|
elif [ "$1" = "arm32" ]; then
|
||||||
ARCHIT="$1"
|
ARCHIT="$1"
|
||||||
|
@ -1,21 +1,50 @@
|
|||||||
#
|
#
|
||||||
# [ win64 ] elinks docker development environment v0.1a
|
# [ win64 ] elinks docker development environment v0.1b
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# [*] base system
|
||||||
|
|
||||||
|
# get latest debian
|
||||||
FROM debian:latest
|
FROM debian:latest
|
||||||
|
|
||||||
RUN apt-get update; apt-get -y install rsync vim screen git make automake gcc-mingw-w64-x86-64 bash g++-mingw-w64-x86-64 libssl-dev
|
# prepare system
|
||||||
|
RUN apt-get update && apt-get -y install bash \
|
||||||
|
rsync vim screen git make automake \
|
||||||
|
gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
|
||||||
|
|
||||||
|
# [*] source build tools
|
||||||
|
|
||||||
|
# install sources build tools and update
|
||||||
|
RUN apt-get install -y apt-src && \
|
||||||
|
grep '^deb ' /etc/apt/sources.list | sed 's/deb /deb-src /' >> /etc/apt/sources.list && \
|
||||||
|
apt-src update
|
||||||
|
|
||||||
|
# [*] install sources
|
||||||
|
|
||||||
|
# install sources for openssl and zlib1g-dev
|
||||||
|
RUN cd /root && apt-src install libssl-dev zlib1g-dev
|
||||||
|
|
||||||
# [*] elinks openssl development support
|
# [*] elinks openssl development support
|
||||||
|
|
||||||
# install sources build tools and update
|
|
||||||
RUN apt-get install -y apt-src && grep '^deb ' /etc/apt/sources.list | sed 's/deb /deb-src /' >> /etc/apt/sources.list && apt-src update
|
|
||||||
|
|
||||||
# install openssl library source code
|
|
||||||
RUN cd /root && apt-src install libssl-dev
|
|
||||||
|
|
||||||
# build openssl library for win64
|
# build openssl library for win64
|
||||||
RUN cd /root && cd `ls -d /root/openssl-*` && ./Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32- --prefix=/usr/local && make && make install
|
RUN cd /root && cd `ls -d /root/openssl-*` && \
|
||||||
|
./Configure mingw64 \
|
||||||
|
--prefix=/usr/local \
|
||||||
|
--cross-compile-prefix=x86_64-w64-mingw32- && \
|
||||||
|
make depend && \
|
||||||
|
make && \
|
||||||
|
make install_runtime_libs && \
|
||||||
|
make install_dev
|
||||||
|
|
||||||
|
# [*} zlib sources
|
||||||
|
|
||||||
|
# build zlib library for win64
|
||||||
|
RUN cd /root && cd `ls -d /root/zlib-*` && \
|
||||||
|
CC="x86_64-w64-mingw32-gcc" \
|
||||||
|
LD="x86_64-w64-mingw32-ldd" \
|
||||||
|
./configure --static --prefix=/usr/local && \
|
||||||
|
make && \
|
||||||
|
make install
|
||||||
|
|
||||||
# [*] elinks sources
|
# [*] elinks sources
|
||||||
|
|
||||||
|
@ -350,8 +350,14 @@ sock_error:
|
|||||||
|
|
||||||
/* Set it non-blocking */
|
/* Set it non-blocking */
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
if (set_nonblocking_fd(sock) < 0)
|
if (set_nonblocking_fd(sock) < 0)
|
||||||
goto sock_error;
|
goto sock_error;
|
||||||
|
#else
|
||||||
|
u_long mode = 1;
|
||||||
|
ioctlsocket(sock, FIONBIO, &mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Bind it to some port */
|
/* Bind it to some port */
|
||||||
|
|
||||||
@ -660,11 +666,16 @@ connect_socket(struct socket *csocket, struct connection_state state)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
if (set_nonblocking_fd(sock) < 0) {
|
if (set_nonblocking_fd(sock) < 0) {
|
||||||
if (errno && !saved_errno) saved_errno = errno;
|
if (errno && !saved_errno) saved_errno = errno;
|
||||||
close(sock);
|
close(sock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
u_long mode = 1;
|
||||||
|
ioctlsocket(sock, FIONBIO, &mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_INET_PTON
|
#ifdef HAVE_INET_PTON
|
||||||
if (pf == PF_INET && to_bind) {
|
if (pf == PF_INET && to_bind) {
|
||||||
|
@ -70,6 +70,10 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define SOCK_SHIFT 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Definition of X509_NAME causes compilation error on WIN32
|
/* Definition of X509_NAME causes compilation error on WIN32
|
||||||
* due to X509_NAME redefinition in wincrypt.h */
|
* due to X509_NAME redefinition in wincrypt.h */
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -433,6 +437,11 @@ ssl_connect(struct socket *socket)
|
|||||||
int ret;
|
int ret;
|
||||||
char *server_name;
|
char *server_name;
|
||||||
struct connection *conn = (struct connection *)socket->conn;
|
struct connection *conn = (struct connection *)socket->conn;
|
||||||
|
#ifdef WIN32
|
||||||
|
int ssl_sock_fd = socket->fd - SOCK_SHIFT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* TODO: Recode server_name to UTF-8. */
|
/* TODO: Recode server_name to UTF-8. */
|
||||||
server_name = get_uri_string(conn->proxied_uri, URI_HOST);
|
server_name = get_uri_string(conn->proxied_uri, URI_HOST);
|
||||||
@ -458,7 +467,12 @@ ssl_connect(struct socket *socket)
|
|||||||
ssl_set_no_tls(socket);
|
ssl_set_no_tls(socket);
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
SSL_set_fd((SSL *)socket->ssl, socket->fd);
|
SSL_set_fd((SSL *)socket->ssl, socket->fd);
|
||||||
|
#else
|
||||||
|
SSL_set_fd((SSL *)socket->ssl, ssl_sock_fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (socket->verify && get_opt_bool("connection.ssl.cert_verify", NULL))
|
if (socket->verify && get_opt_bool("connection.ssl.cert_verify", NULL))
|
||||||
SSL_set_verify((SSL *)socket->ssl, SSL_VERIFY_PEER
|
SSL_set_verify((SSL *)socket->ssl, SSL_VERIFY_PEER
|
||||||
|
@ -77,13 +77,6 @@
|
|||||||
int
|
int
|
||||||
set_nonblocking_fd(int fd)
|
set_nonblocking_fd(int fd)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
|
||||||
/* on current mingw (202204)
|
|
||||||
* this is correct usage of winsock
|
|
||||||
* when compiling for win32 */
|
|
||||||
u_long mode = 1; // set non-blocking socket
|
|
||||||
return ioctlsocket(fd, FIONBIO, &mode);
|
|
||||||
# else
|
|
||||||
#if defined(O_NONBLOCK) || defined(O_NDELAY)
|
#if defined(O_NONBLOCK) || defined(O_NDELAY)
|
||||||
int flags = fcntl(fd, F_GETFL, 0);
|
int flags = fcntl(fd, F_GETFL, 0);
|
||||||
|
|
||||||
@ -101,8 +94,6 @@ set_nonblocking_fd(int fd)
|
|||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a file descriptor to blocking mode. It returns a non-zero value on
|
/* Set a file descriptor to blocking mode. It returns a non-zero value on
|
||||||
@ -110,13 +101,6 @@ set_nonblocking_fd(int fd)
|
|||||||
int
|
int
|
||||||
set_blocking_fd(int fd)
|
set_blocking_fd(int fd)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
|
||||||
/* on current mingw (202204)
|
|
||||||
* this is correct usage of winsock
|
|
||||||
* when compiling for win32 */
|
|
||||||
u_long mode = 0; // set blocking socket
|
|
||||||
return ioctlsocket(fd, FIONBIO, &mode);
|
|
||||||
# else
|
|
||||||
#if defined(O_NONBLOCK) || defined(O_NDELAY)
|
#if defined(O_NONBLOCK) || defined(O_NDELAY)
|
||||||
int flags = fcntl(fd, F_GETFL, 0);
|
int flags = fcntl(fd, F_GETFL, 0);
|
||||||
|
|
||||||
@ -134,7 +118,6 @@ set_blocking_fd(int fd)
|
|||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -371,9 +371,13 @@ win32_ioctl(int fd, long option, int *flag)
|
|||||||
int
|
int
|
||||||
win32_socket(int pf, int type, int protocol)
|
win32_socket(int pf, int type, int protocol)
|
||||||
{
|
{
|
||||||
SOCKET s = socket(pf, type, protocol);
|
// SOCKET s = socket(pf, type, protocol);
|
||||||
|
|
||||||
|
int s;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
s = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (s == INVALID_SOCKET) {
|
if (s == INVALID_SOCKET) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
errno = WSAGetLastError();
|
errno = WSAGetLastError();
|
||||||
@ -627,6 +631,8 @@ select_one_loop(int num_fds, struct fd_set *rd, struct fd_set *wr,
|
|||||||
} else if (sel_rc < 0) {
|
} else if (sel_rc < 0) {
|
||||||
errno = WSAGetLastError();
|
errno = WSAGetLastError();
|
||||||
}
|
}
|
||||||
|
/* Lower CPU Usage WIN64 */
|
||||||
|
Sleep (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +670,7 @@ int win32_select (int num_fds, struct fd_set *rd, struct fd_set *wr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
int errnol = 0;
|
||||||
|
|
||||||
for (rc = 0; !expired; ) {
|
for (rc = 0; !expired; ) {
|
||||||
rc += select_one_loop (num_fds, &tmp_rd, wr, &tmp_ex);
|
rc += select_one_loop (num_fds, &tmp_rd, wr, &tmp_ex);
|
||||||
@ -679,6 +685,8 @@ int win32_select (int num_fds, struct fd_set *rd, struct fd_set *wr,
|
|||||||
expired = TRUE;
|
expired = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lower CPU Usage WIN64 */
|
||||||
|
Sleep (1);
|
||||||
if (rc) break;
|
if (rc) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,7 +702,7 @@ int win32_select (int num_fds, struct fd_set *rd, struct fd_set *wr,
|
|||||||
else rc++;
|
else rc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("-> rc %d, err %d", rc, rc < 0 ? errno : 0);
|
TRACE("-> rc %d, err %d", rc, rc < 0 ? errnol : 0);
|
||||||
|
|
||||||
if (get_cmd_opt_int("verbose") == 2)
|
if (get_cmd_opt_int("verbose") == 2)
|
||||||
select_dump(num_fds, rd, wr, ex);
|
select_dump(num_fds, rd, wr, ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user