1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/src/protocol/protocol.h

76 lines
1.8 KiB
C
Raw Normal View History

#ifndef EL__PROTOCOL_PROTOCOL_H
#define EL__PROTOCOL_PROTOCOL_H
#include "main/module.h"
#ifdef __cplusplus
extern "C" {
#endif
struct connection;
struct session;
struct terminal;
struct uri;
enum protocol {
PROTOCOL_ABOUT,
PROTOCOL_BITTORRENT,
Fix blacklist crash in BitTorrent make_bittorrent_peer_connection() used to construct a struct uri on the stack. This was hacky but worked nicely because the struct uri was not really accessed after make_connection() returned. However, since commit a83ff1f565a4a7bc25a4b8353ee26bc1b97410e3, the struct uri is also needed when the connection is being closed. Valgrind shows: Invalid read of size 2 at 0x8100764: get_blacklist_entry (blacklist.c:33) by 0x8100985: del_blacklist_entry (blacklist.c:64) by 0x80DA579: complete_connect_socket (socket.c:448) by 0x80DA84A: connected (socket.c:513) by 0x80D0DDF: select_loop (select.c:297) by 0x80D00C6: main (main.c:353) Address 0xBEC3BFAE is just below the stack ptr. To suppress, use: --workaround-gcc296-bugs=yes To fix this, allocate the struct uri on the heap instead, by constructing a string and giving that to get_uri(). This string cannot use the "bittorrent" URI scheme because parse_uri() does not recognize the host and port fields in that. (The "bittorrent" scheme has protocol_backend.free_syntax = 1 in order to support strings like "bittorrent:http://beta.legaltorrents.com/get/159-noisome-beasts".) Instead, define a new "bittorrent-peer" URI scheme for this purpose. If the user attempts to use this URI scheme, its handler aborts the connection with an error; but when make_bittorrent_peer_connection() uses a bittorrent-peer URI, the handler is not called. This change also lets get_uri() set the ipv6 flag if peer_info->ip is an IPv6 address literal. Reported by Witold Filipczyk.
2008-09-06 23:10:52 -04:00
PROTOCOL_BITTORRENT_PEER,
PROTOCOL_DATA,
PROTOCOL_FILE,
PROTOCOL_FINGER,
2006-01-16 05:40:13 -05:00
PROTOCOL_FSP,
PROTOCOL_FTP,
PROTOCOL_GEMINI,
PROTOCOL_GOPHER,
PROTOCOL_HTTP,
PROTOCOL_HTTPS,
PROTOCOL_JAVASCRIPT,
PROTOCOL_MAILCAP,
PROTOCOL_NEWS,
PROTOCOL_NNTP,
PROTOCOL_NNTPS,
PROTOCOL_PROXY,
PROTOCOL_SMB,
PROTOCOL_SNEWS,
/* Keep these last! */
PROTOCOL_UNKNOWN,
PROTOCOL_USER,
PROTOCOL_LUA,
/* For protocol backend index checking */
PROTOCOL_BACKENDS,
};
2022-01-28 11:19:11 -05:00
typedef unsigned int protocol_T;
/* Besides the session an external handler also takes the url as an argument */
typedef void (protocol_handler_T)(struct connection *);
typedef void (protocol_external_handler_T)(struct session *, struct uri *);
/* Accessors for the protocol backends. */
2022-01-28 11:19:11 -05:00
int get_protocol_port(protocol_T protocol);
int get_protocol_need_slashes(protocol_T protocol);
int get_protocol_keep_double_slashes(protocol_T protocol);
int get_protocol_need_slash_after_host(protocol_T protocol);
int get_protocol_free_syntax(protocol_T protocol);
int get_protocol_need_ssl(protocol_T protocol);
2022-01-28 11:19:11 -05:00
protocol_handler_T *get_protocol_handler(protocol_T protocol);
protocol_external_handler_T *get_protocol_external_handler(struct terminal *, struct uri *);
/* Resolves the given protocol @name with length @namelen to a known protocol,
* PROTOCOL_UNKOWN or PROTOCOL_INVALID if no protocol part could be identified.
* User defined protocols (configurable via protocol.user) takes precedence. */
2022-01-28 11:19:11 -05:00
protocol_T get_protocol(char *name, int namelen);
extern struct module protocol_module;
#ifdef __cplusplus
}
#endif
#endif