5.3 Gateways in General

The library provides a general gateway layer through which all networking passes. It can both control access to the network and provide access through gateways in firewalls. This may make direct connections in some cases and pass through some sort of gateway in others.1 The library’s basic function responsible for making connections is url-open-stream.

Function: url-open-stream name buffer host service

Open a stream to host, possibly via a gateway. The other arguments are as for open-network-stream. This will not make a connection if url-gateway-unplugged is non-nil.

Variable: url-gateway-local-host-regexp

This is a regular expression that matches local hosts that do not require the use of a gateway. If nil, all connections are made through the gateway.

Variable: url-gateway-method

This variable controls which gateway method is used. It may be useful to bind it temporarily in some applications. It has values taken from a list of symbols. Possible values are:


Use this method if you must first telnet and log into a gateway host, and then run telnet from that host to connect to outside machines.


Use if the firewall has a SOCKS gateway running on it. The SOCKS v5 protocol is defined in RFC 1928.


This method uses Emacs’s builtin networking directly. This is the default. It can be used only if there is no firewall blocking access.

The following variables control the gateway methods.

User Option: url-gateway-telnet-host

The gateway host to telnet to. Once logged in there, you then telnet out to the hosts you want to connect to.

User Option: url-gateway-telnet-parameters

This should be a list of parameters to pass to the telnet program.

User Option: url-gateway-telnet-password-prompt

This is a regular expression that matches the password prompt when logging in.

User Option: url-gateway-telnet-login-prompt

This is a regular expression that matches the username prompt when logging in.

User Option: url-gateway-telnet-user-name

The username to log in with.

User Option: url-gateway-telnet-password

The password to send when logging in.

User Option: url-gateway-prompt-pattern

This is a regular expression that matches the shell prompt.

User Option: socks-server

This specifies the default server, it takes the form ("Default server" server port version) where version can be either 4 or 5.

Variable: socks-password

If this is nil then you will be asked for the password, otherwise it will be used as the password for authenticating you to the SOCKS server.

Variable: socks-username

This is the username to use when authenticating yourself to the SOCKS server. By default this is your login name.

Variable: socks-timeout

This controls how long, in seconds, to wait for responses from the SOCKS server; it is 5 by default.

User Option: socks-nslookup-program

This the ‘nslookup’ program. It is "nslookup" by default.



Proxies (which only operate over HTTP) are implemented using this.