1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[ win64 ] changes for win64 with ssl in docker

This commit is contained in:
Unknown 2022-04-30 18:49:56 +00:00
parent b76f48c683
commit 5434b211f0
6 changed files with 88 additions and 40 deletions

View File

@ -5,15 +5,16 @@
clear
echo ' --/ \--'
echo ' --[ Welcome to the elinks build helper ]--'
echo ' --[ ]--'
echo ' --[ [*] select the architecture 1-4 ]--'
echo ' --[ [*] use option 5 for config ]--'
echo ' --[ [*] use option 6 for make ]--'
echo ' --[ [*] use option 7 for test ]--'
echo ' --[ [*] use option 8 for publishing ]--'
echo ' --\ /--'
echo ' --/ \--'
echo ' --[ Welcome to the elinks build helper ]--'
echo ' --[ ]--'
echo ' --[ [*] use option 1 to change arch ]--'
echo ' --[ [*] use option 4 to config and make ]--'
echo ' --[ [*] use option 5 for config ]--'
echo ' --[ [*] use option 6 for make ]--'
echo ' --[ [*] use option 7 for test ]--'
echo ' --[ [*] use option 8 for publishing ]--'
echo ' --\ /--'
echo ' '
gen_conf() {
@ -33,6 +34,7 @@ configure() {
CC=$1 \
LD=$2 \
LDFLAGS=$4 \
CFLAGS="-O2 -I/usr/local/include" \
LIBS=$5 \
CXXFLAGS=$6 \
PKG_CONFIG="./pkg-config.sh" \
@ -43,7 +45,7 @@ configure() {
--enable-fastmem \
--enable-utf-8 \
--with-static \
--without-openssl \
--with-openssl \
--without-quickjs \
--disable-88-colors \
--disable-backtrace \
@ -51,6 +53,7 @@ configure() {
--disable-debug \
--disable-cgi \
--disable-combining \
--disable-gpm \
--disable-gopher \
--disable-nls \
--disable-ipv6 \
@ -178,7 +181,7 @@ set_arch() {
MAKE_HOST="x86_64-w64-mingw32"
BIN_SUFFIX=".exe"
CXXFLAGS="-I/usr/local/include"
LDFLAGS=""
LDFLAGS="-L/usr/local/lib"
LIBS="-lws2_32"
elif [ "$1" = "arm32" ]; then
ARCHIT="$1"

View File

@ -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
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
# 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
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

View File

@ -350,8 +350,14 @@ sock_error:
/* Set it non-blocking */
#ifndef WIN32
if (set_nonblocking_fd(sock) < 0)
goto sock_error;
#else
u_long mode = 1;
ioctlsocket(sock, FIONBIO, &mode);
#endif
/* Bind it to some port */
@ -660,11 +666,16 @@ connect_socket(struct socket *csocket, struct connection_state state)
continue;
}
#ifndef WIN32
if (set_nonblocking_fd(sock) < 0) {
if (errno && !saved_errno) saved_errno = errno;
close(sock);
continue;
}
#else
u_long mode = 1;
ioctlsocket(sock, FIONBIO, &mode);
#endif
#ifdef HAVE_INET_PTON
if (pf == PF_INET && to_bind) {

View File

@ -70,6 +70,10 @@
#endif
#ifdef WIN32
#define SOCK_SHIFT 1024
#endif
/* Definition of X509_NAME causes compilation error on WIN32
* due to X509_NAME redefinition in wincrypt.h */
#ifdef WIN32
@ -433,6 +437,11 @@ ssl_connect(struct socket *socket)
int ret;
char *server_name;
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. */
server_name = get_uri_string(conn->proxied_uri, URI_HOST);
@ -458,7 +467,12 @@ ssl_connect(struct socket *socket)
ssl_set_no_tls(socket);
#ifdef USE_OPENSSL
#ifndef WIN32
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))
SSL_set_verify((SSL *)socket->ssl, SSL_VERIFY_PEER

View File

@ -77,13 +77,6 @@
int
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)
int flags = fcntl(fd, F_GETFL, 0);
@ -101,8 +94,6 @@ set_nonblocking_fd(int fd)
#else
return 0;
#endif
#endif
}
/* Set a file descriptor to blocking mode. It returns a non-zero value on
@ -110,13 +101,6 @@ set_nonblocking_fd(int fd)
int
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)
int flags = fcntl(fd, F_GETFL, 0);
@ -134,7 +118,6 @@ set_blocking_fd(int fd)
#else
return 0;
#endif
#endif
}
void

View File

@ -371,9 +371,13 @@ win32_ioctl(int fd, long option, int *flag)
int
win32_socket(int pf, int type, int protocol)
{
SOCKET s = socket(pf, type, protocol);
// SOCKET s = socket(pf, type, protocol);
int s;
int rc;
s = socket(PF_INET, SOCK_STREAM, 0);
if (s == INVALID_SOCKET) {
rc = -1;
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) {
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; ) {
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;
}
/* Lower CPU Usage WIN64 */
Sleep (1);
if (rc) break;
}
@ -694,7 +702,7 @@ int win32_select (int num_fds, struct fd_set *rd, struct fd_set *wr,
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)
select_dump(num_fds, rd, wr, ex);