Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27639c2e6d | ||
|
|
c054f8dc20 | ||
|
|
44b908ff2b | ||
|
|
55ef361999 | ||
|
|
231954696e | ||
|
|
b9ed17e937 | ||
|
|
a5c137c06d | ||
|
|
abf8ae5117 | ||
|
|
8f3e23d3de | ||
|
|
21d8ac90e8 | ||
|
|
f76eea8931 | ||
|
|
fdbfa98938 | ||
|
|
5ceb31a97e | ||
|
|
f6ecdab9c5 | ||
|
|
bea2fc990d | ||
|
|
a409d1cee6 | ||
|
|
4c3f5908e3 | ||
|
|
79d3f1992e | ||
|
|
c42b8526f0 | ||
|
|
053bd8d5d6 | ||
|
|
36f8df2011 | ||
|
|
880e5edf1b | ||
|
|
a284706e78 | ||
|
|
b1de821740 | ||
|
|
7e33e463bb | ||
|
|
f7926b75fc | ||
|
|
f9d7f3d5c8 | ||
|
|
9c2919f01d | ||
|
|
19c2d8df76 | ||
|
|
888b578907 | ||
|
|
2972046f5f | ||
|
|
6f16b43387 | ||
|
|
7a2b8b1888 | ||
|
|
89c5fc8680 | ||
|
|
bb59a374a1 | ||
|
|
a0bbd2fa28 | ||
|
|
047ecf672c | ||
|
|
73bc067641 | ||
|
|
8ccfcc8c06 | ||
|
|
caa6f5ed6a | ||
|
|
1bc2132e1d | ||
|
|
d771d7bdfd | ||
|
|
49ea4c7ccd | ||
|
|
318987c100 | ||
|
|
a85e04d816 | ||
|
|
48c540d83b | ||
|
|
c75f4b29a1 | ||
|
|
7ee9910cac |
11
Makefile
11
Makefile
@@ -4,12 +4,15 @@
|
|||||||
# solusipse.net
|
# solusipse.net
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
|
|
||||||
CC=gcc
|
CFLAGS+=-pthread -O2
|
||||||
CFLAGS=-pthread -O2
|
|
||||||
prefix=/usr/local
|
prefix=/usr/local
|
||||||
|
|
||||||
all: fiche.c
|
all: fiche
|
||||||
$(CC) -o fiche $(CFLAGS) fiche.c
|
|
||||||
|
|
||||||
install: fiche
|
install: fiche
|
||||||
install -m 0755 fiche $(prefix)/bin
|
install -m 0755 fiche $(prefix)/bin
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f fiche
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|||||||
243
README.md
243
README.md
@@ -1,242 +1,5 @@
|
|||||||
fiche [](https://travis-ci.org/solusipse/fiche)
|
# fiche
|
||||||
=====
|
|
||||||
|
|
||||||
Command line pastebin for sharing terminal output.
|
## Warning
|
||||||
|
|
||||||
## Installation ##
|
Do not use code from this branch. Please use code from [master](https://github.com/solusipse/fiche) instead.
|
||||||
|
|
||||||
1. Clone into repository:
|
|
||||||
|
|
||||||
```
|
|
||||||
https://github.com/solusipse/fiche.git
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Build program:
|
|
||||||
|
|
||||||
```
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Install:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Client-side usage ##
|
|
||||||
|
|
||||||
Self explanatory live examples:
|
|
||||||
|
|
||||||
```
|
|
||||||
ls -la | nc localhost 9999
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
cat file.txt | nc solusipse.net 9999
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
echo just testing! | nc code.solusipse.net 9999
|
|
||||||
```
|
|
||||||
|
|
||||||
If you haven't already set up your server on localhost, try second or third command. My personal server is
|
|
||||||
providing fiche-based service all the time on this address `solusipse.net` and this port `9999`.
|
|
||||||
|
|
||||||
- To upload text you need to have netcat installed (to check if netcat is installed, simply type ```nc``` in terminal).
|
|
||||||
|
|
||||||
## Server-side usage ##
|
|
||||||
|
|
||||||
```
|
|
||||||
usage: fiche [-pbsdolBuw].
|
|
||||||
[-d domain] [-p port] [-s slug size]
|
|
||||||
[-o output directory] [-B buffer size] [-u user name]
|
|
||||||
[-l log file] [-b banlist] [-w whitelist]
|
|
||||||
```
|
|
||||||
|
|
||||||
These are command line arguments. You don't have to provide any, but providing basic is recommended. Without them, program
|
|
||||||
will use these default settings:
|
|
||||||
|
|
||||||
```
|
|
||||||
domain = "http://localhost/";
|
|
||||||
basedir= "~/code/";
|
|
||||||
port = 9999;
|
|
||||||
slug_size = 4;
|
|
||||||
buffer_size = 8192;
|
|
||||||
```
|
|
||||||
|
|
||||||
### Arguments ###
|
|
||||||
|
|
||||||
Most important is providing **basedir** and **domain**.
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Basedir ####
|
|
||||||
|
|
||||||
Basedir should be **absolute** path to directory where you would like to store text files.
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -o /absolute/path/to/directory/
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -o /home/www/code/
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Domain ####
|
|
||||||
|
|
||||||
Domain should be provided in such format ```domain.com```.
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -d domain.com
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -d subdomain.domain.com
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Slug size ####
|
|
||||||
|
|
||||||
This will force fiche to create random slugs with given length, example:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -s 6
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
http://domain.com/abcdef/
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### User name ####
|
|
||||||
|
|
||||||
If you use fiche as service (see details below) you may want to save files as other user, to do that use `-u` option,
|
|
||||||
there's example:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -u http
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Buffersize ####
|
|
||||||
|
|
||||||
This parameter defines max file size uploaded by user, by default it is set to `32768`.
|
|
||||||
Use `-B` parameter to change it:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -B 2048
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Log file ###
|
|
||||||
|
|
||||||
Path to file where all logs will be stored:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -l /home/www/fiche-log.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Ban list ###
|
|
||||||
|
|
||||||
Path to file where you provided all banned IP adresses:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -b /home/www/fiche-bans.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### White list ####
|
|
||||||
|
|
||||||
If whitelist mode is enabled, only addresses from list will be able to upload files. There's example:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -w /home/www/fiche-whitelist.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Whitelist and banlist syntax ####
|
|
||||||
|
|
||||||
There is no specific syntax, there files may contain not only addresses.
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
#### Examples ####
|
|
||||||
|
|
||||||
Logging connections with banlist:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -d domain.com -l /home/www/log.txt -b /home/www/bans.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
Only for personal use with whitelist
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -d domain.com -w /home/www/whitelist.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
Custom output directory, bigger slug size, reduced buffer, custom port:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -d domain.com -o /media/disk/fiche/ -s 8 -B 2048 -p 6666
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Running as service ##
|
|
||||||
You can run fiche as service, there is simple systemd example:
|
|
||||||
|
|
||||||
```
|
|
||||||
[Unit]
|
|
||||||
Description=FICHE-SERVER
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/local/bin/fiche -d code.solusipse.net -o /home/www/code/ -l /home/www/log.txt
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
In service mode you have to set output directory with `-o` parameter, there's example:
|
|
||||||
|
|
||||||
```
|
|
||||||
fiche -o /home/www/code/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Webserver ##
|
|
||||||
|
|
||||||
To make files available for users, you need to host them somehow. Http server is easiest option. Just set root
|
|
||||||
directory to ```BASEDIR```.
|
|
||||||
|
|
||||||
There is sample configuration for nginx:
|
|
||||||
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name mysite.com www.mysite.com;
|
|
||||||
charset utf-8;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
root /home/www/code/;
|
|
||||||
index index.txt index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## License ##
|
|
||||||
|
|
||||||
Fiche is MIT licensed.
|
|
||||||
|
|||||||
297
fiche.c
Executable file → Normal file
297
fiche.c
Executable file → Normal file
@@ -9,11 +9,15 @@ Live example: http://code.solusipse.net/
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
usage: fiche [-pbsdolBuw].
|
usage: fiche [-DepbsdolBuw].
|
||||||
[-d domain] [-p port] [-s slug size]
|
[-D] [-e] [-d domain] [-p port] [-s slug size]
|
||||||
[-o output directory] [-B buffer size] [-u user name]
|
[-o output directory] [-B buffer size] [-u user name]
|
||||||
[-l log file] [-b banlist] [-w whitelist]
|
[-l log file] [-b banlist] [-w whitelist]
|
||||||
|
|
||||||
|
-D option is for daemonizing fiche
|
||||||
|
|
||||||
|
-e option is for using an extended character set for the URL
|
||||||
|
|
||||||
Compile with Makefile or manually with -O2 and -pthread flags.
|
Compile with Makefile or manually with -O2 and -pthread flags.
|
||||||
To install use `make install` command.
|
To install use `make install` command.
|
||||||
|
|
||||||
@@ -24,6 +28,7 @@ $ cat fiche.c | nc localhost 9999
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
#include "fiche.h"
|
#include "fiche.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@@ -31,6 +36,18 @@ int main(int argc, char **argv)
|
|||||||
time_seed = time(0);
|
time_seed = time(0);
|
||||||
|
|
||||||
parse_parameters(argc, argv);
|
parse_parameters(argc, argv);
|
||||||
|
set_domain_name();
|
||||||
|
|
||||||
|
if (getuid() == 0)
|
||||||
|
{
|
||||||
|
if (UID == -1)
|
||||||
|
error("user not set");
|
||||||
|
if (setgid(GID) != 0)
|
||||||
|
error("Unable to drop group privileges");
|
||||||
|
if (setuid(UID) != 0)
|
||||||
|
error("Unable to drop user privileges");
|
||||||
|
}
|
||||||
|
|
||||||
if (BASEDIR == NULL)
|
if (BASEDIR == NULL)
|
||||||
set_basedir();
|
set_basedir();
|
||||||
|
|
||||||
@@ -42,39 +59,79 @@ int main(int argc, char **argv)
|
|||||||
listen_socket = create_socket();
|
listen_socket = create_socket();
|
||||||
setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval , sizeof(int));
|
setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval , sizeof(int));
|
||||||
|
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct sockaddr_in6 server_address6;
|
||||||
|
if (IPv6)
|
||||||
|
{
|
||||||
|
server_address6 = set_address6(server_address6);
|
||||||
|
bind_to_port6(listen_socket, server_address6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
if (1) {
|
||||||
|
#endif
|
||||||
server_address = set_address(server_address);
|
server_address = set_address(server_address);
|
||||||
bind_to_port(listen_socket, server_address);
|
bind_to_port(listen_socket, server_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DAEMON)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
if (pid == -1)
|
||||||
|
error("Failed to fork");
|
||||||
|
if (pid == 0)
|
||||||
while (1) perform_connection(listen_socket);
|
while (1) perform_connection(listen_socket);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
while (1) perform_connection(listen_socket);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *thread_connection(void *args)
|
void *thread_connection(void *args)
|
||||||
{
|
{
|
||||||
int connection_socket = ((struct thread_arguments *) args ) -> connection_socket;
|
int connection_socket = ((struct thread_arguments *) args ) -> connection_socket;
|
||||||
struct sockaddr_in client_address = ((struct thread_arguments *) args ) -> client_address;
|
struct sockaddr_in client_address;
|
||||||
|
struct client_data data;
|
||||||
struct client_data data = get_client_address(client_address);
|
#if (HAVE_INET6)
|
||||||
|
struct sockaddr_in6 client_address6;
|
||||||
|
if (IPv6)
|
||||||
|
{
|
||||||
|
client_address6 = ((struct thread_arguments *) args ) -> client_address6;
|
||||||
|
data = get_client_address6(client_address6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
if (1) {
|
||||||
|
#endif
|
||||||
|
client_address = ((struct thread_arguments *) args ) -> client_address;
|
||||||
|
data = get_client_address(client_address);
|
||||||
|
}
|
||||||
|
|
||||||
char buffer[BUFSIZE];
|
char buffer[BUFSIZE];
|
||||||
bzero(buffer, BUFSIZE);
|
bzero(buffer, BUFSIZE);
|
||||||
int status = recv(connection_socket, buffer, BUFSIZE, MSG_WAITALL);
|
int status = recv(connection_socket, buffer, BUFSIZE, MSG_WAITALL);
|
||||||
|
|
||||||
if (WHITELIST != NULL)
|
if (WHITELIST != NULL && check_whitelist(data.ip_address) == NULL)
|
||||||
if (check_whitelist(data.ip_address) == NULL)
|
|
||||||
{
|
{
|
||||||
display_info(data, NULL, "Rejected connection from unknown user.");
|
display_info(data, NULL, "Rejected connection from unknown user.");
|
||||||
save_log(NULL, data.ip_address, data.hostname);
|
save_log(NULL, data.ip_address, data.hostname);
|
||||||
write(connection_socket, "You are not whitelisted!\n", 26);
|
if (write(connection_socket, "You are not whitelisted!\n", 26) < 0)
|
||||||
|
printf("Error writing on stream socket\n");
|
||||||
close(connection_socket);
|
close(connection_socket);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BANLIST != NULL)
|
if (BANLIST != NULL && check_banlist(data.ip_address) != NULL)
|
||||||
if (check_banlist(data.ip_address) != NULL)
|
|
||||||
{
|
{
|
||||||
display_info(data, NULL, "Rejected connection from banned user.");
|
display_info(data, NULL, "Rejected connection from banned user.");
|
||||||
save_log(NULL, data.ip_address, data.hostname);
|
save_log(NULL, data.ip_address, data.hostname);
|
||||||
write(connection_socket, "You are banned!\n", 17);
|
if (write(connection_socket, "You are banned!\n", 17) < 0)
|
||||||
|
printf("Error writing on stream socket\n");
|
||||||
close(connection_socket);
|
close(connection_socket);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
@@ -89,13 +146,15 @@ void *thread_connection(void *args)
|
|||||||
save_log(slug, data.ip_address, data.hostname);
|
save_log(slug, data.ip_address, data.hostname);
|
||||||
char response[strlen(slug) + strlen(DOMAIN) + 2];
|
char response[strlen(slug) + strlen(DOMAIN) + 2];
|
||||||
snprintf(response, sizeof response, "%s%s\n", DOMAIN, slug);
|
snprintf(response, sizeof response, "%s%s\n", DOMAIN, slug);
|
||||||
write(connection_socket, response, strlen(response));
|
if (write(connection_socket, response, strlen(response)) < 0)
|
||||||
|
printf("Error writing on stream socket\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
display_info(data, NULL, "Invalid connection.");
|
display_info(data, NULL, "Invalid connection.");
|
||||||
save_log(NULL, data.ip_address, data.hostname);
|
save_log(NULL, data.ip_address, data.hostname);
|
||||||
write(connection_socket, "Use netcat.\n", 12);
|
if (write(connection_socket, "Use netcat.\n", 12) < 0)
|
||||||
|
printf("Error writing on stream socket\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
close(connection_socket);
|
close(connection_socket);
|
||||||
@@ -107,33 +166,49 @@ void perform_connection(int listen_socket)
|
|||||||
pthread_t thread_id;
|
pthread_t thread_id;
|
||||||
struct sockaddr_in client_address;
|
struct sockaddr_in client_address;
|
||||||
|
|
||||||
int address_lenght = sizeof(client_address);
|
int address_length;
|
||||||
int connection_socket = accept(listen_socket, (struct sockaddr *) &client_address, (void *) &address_lenght);
|
int connection_socket;
|
||||||
|
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct sockaddr_in6 client_address6;
|
||||||
|
if (IPv6)
|
||||||
|
{
|
||||||
|
address_length = sizeof(client_address6);
|
||||||
|
connection_socket = accept(listen_socket, (struct sockaddr *) &client_address6, (void *) &address_length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
if (1) {
|
||||||
|
#endif
|
||||||
|
address_length = sizeof(client_address);
|
||||||
|
connection_socket = accept(listen_socket, (struct sockaddr *) &client_address, (void *) &address_length);
|
||||||
|
}
|
||||||
|
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
timeout.tv_sec = 5;
|
timeout.tv_sec = 5;
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
if (setsockopt (connection_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)) < 0)
|
if (setsockopt (connection_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)) < 0)
|
||||||
error("ERROR while setting setsockopt timeout");
|
error("while setting setsockopt timeout");
|
||||||
if (setsockopt (connection_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)) < 0)
|
if (setsockopt (connection_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)) < 0)
|
||||||
error("ERROR while setting setsockopt timeout");
|
error("while setting setsockopt timeout");
|
||||||
|
|
||||||
struct thread_arguments arguments;
|
struct thread_arguments arguments;
|
||||||
arguments.connection_socket = connection_socket;
|
arguments.connection_socket = connection_socket;
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
if (IPv6)
|
||||||
|
arguments.client_address6 = client_address6;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
arguments.client_address = client_address;
|
arguments.client_address = client_address;
|
||||||
|
|
||||||
if (pthread_create(&thread_id, NULL, &thread_connection, &arguments) != 0)
|
if (pthread_create(&thread_id, NULL, &thread_connection, &arguments) != 0)
|
||||||
error("ERROR on thread creation");
|
error("on thread creation");
|
||||||
else
|
else
|
||||||
pthread_detach(thread_id);
|
pthread_detach(thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_date()
|
|
||||||
{
|
|
||||||
printf("%s\n", get_date());
|
|
||||||
}
|
|
||||||
|
|
||||||
char *get_date()
|
char *get_date()
|
||||||
{
|
{
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
@@ -157,7 +232,7 @@ struct client_data get_client_address(struct sockaddr_in client_address)
|
|||||||
hostp = gethostbyaddr((const char *)&client_address.sin_addr.s_addr, sizeof(client_address.sin_addr.s_addr), AF_INET);
|
hostp = gethostbyaddr((const char *)&client_address.sin_addr.s_addr, sizeof(client_address.sin_addr.s_addr), AF_INET);
|
||||||
if (hostp == NULL)
|
if (hostp == NULL)
|
||||||
{
|
{
|
||||||
printf("ERROR: Couldn't obtain client's hostname\n");
|
printf("WARNING: Couldn't obtain client's hostname\n");
|
||||||
data.hostname = "n/a";
|
data.hostname = "n/a";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -166,7 +241,7 @@ struct client_data get_client_address(struct sockaddr_in client_address)
|
|||||||
hostaddrp = inet_ntoa(client_address.sin_addr);
|
hostaddrp = inet_ntoa(client_address.sin_addr);
|
||||||
if (hostaddrp == NULL)
|
if (hostaddrp == NULL)
|
||||||
{
|
{
|
||||||
printf("ERROR: Couldn't obtain client's address\n");
|
printf("WARNING: Couldn't obtain client's address\n");
|
||||||
data.ip_address = "n/a";
|
data.ip_address = "n/a";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -175,6 +250,36 @@ struct client_data get_client_address(struct sockaddr_in client_address)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct client_data get_client_address6(struct sockaddr_in6 client_address6)
|
||||||
|
{
|
||||||
|
struct hostent *hostp;
|
||||||
|
struct client_data data;
|
||||||
|
static char hostaddrp[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
|
hostp = gethostbyaddr((const char *)&client_address6.sin6_addr, sizeof(client_address6.sin6_addr), AF_INET6);
|
||||||
|
if (hostp == NULL)
|
||||||
|
{
|
||||||
|
printf("WARNING: Couldn't obtain client's hostname\n");
|
||||||
|
data.hostname = "n/a";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
data.hostname = hostp->h_name;
|
||||||
|
|
||||||
|
inet_ntop(AF_INET6, &(client_address6.sin6_addr), hostaddrp,
|
||||||
|
INET6_ADDRSTRLEN);
|
||||||
|
if (hostaddrp == NULL)
|
||||||
|
{
|
||||||
|
printf("WARNING: Couldn't obtain client's address\n");
|
||||||
|
data.ip_address = "n/a";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
data.ip_address = hostaddrp;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void save_log(char *slug, char *hostaddrp, char *h_name)
|
void save_log(char *slug, char *hostaddrp, char *h_name)
|
||||||
{
|
{
|
||||||
if (LOG != NULL)
|
if (LOG != NULL)
|
||||||
@@ -195,12 +300,17 @@ void save_log(char *slug, char *hostaddrp, char *h_name)
|
|||||||
|
|
||||||
void display_info(struct client_data data, char *slug, char *message)
|
void display_info(struct client_data data, char *slug, char *message)
|
||||||
{
|
{
|
||||||
|
if (DAEMON)
|
||||||
|
return;
|
||||||
|
|
||||||
if (slug == NULL)
|
if (slug == NULL)
|
||||||
printf("%s\n", message);
|
printf("%s\n", message);
|
||||||
else printf("Saved to: %s\n", slug);
|
else
|
||||||
display_date();
|
printf("Saved to: %s\n", slug);
|
||||||
|
|
||||||
|
printf("%s\n", get_date());
|
||||||
printf("Client: %s (%s)\n", data.ip_address, data.hostname);
|
printf("Client: %s (%s)\n", data.ip_address, data.hostname);
|
||||||
display_line();
|
printf("====================================\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *check_banlist(char *ip_address)
|
char *check_banlist(char *ip_address)
|
||||||
@@ -217,13 +327,18 @@ char *check_whitelist(char *ip_address)
|
|||||||
|
|
||||||
void load_list(char *file_path, int type)
|
void load_list(char *file_path, int type)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(file_path, "r");
|
FILE *fp;
|
||||||
|
|
||||||
|
if (( fp = fopen(file_path, "r")) == NULL )
|
||||||
|
error("cannot load list");
|
||||||
|
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
long fsize = ftell(fp);
|
long fsize = ftell(fp);
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
|
||||||
char *buffer = malloc(fsize + 1);
|
char *buffer = malloc(fsize + 1);
|
||||||
fread(buffer, fsize, 1, fp);
|
if (fread(buffer, fsize, 1, fp) != fsize)
|
||||||
|
error("reading list failed");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
buffer[fsize] = 0;
|
buffer[fsize] = 0;
|
||||||
@@ -238,13 +353,18 @@ void load_list(char *file_path, int type)
|
|||||||
|
|
||||||
int create_socket()
|
int create_socket()
|
||||||
{
|
{
|
||||||
int lsocket = socket(AF_INET, SOCK_STREAM, 0);
|
int lsocket;
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
if (IPv6)
|
||||||
|
lsocket = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
lsocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (lsocket < 0)
|
if (lsocket < 0)
|
||||||
{
|
error("Couldn't open socket");
|
||||||
error("ERROR: Couldn't open socket");
|
|
||||||
return 0;
|
return lsocket;
|
||||||
}
|
|
||||||
else return lsocket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in set_address(struct sockaddr_in server_address)
|
struct sockaddr_in set_address(struct sockaddr_in server_address)
|
||||||
@@ -256,14 +376,35 @@ struct sockaddr_in set_address(struct sockaddr_in server_address)
|
|||||||
return server_address;
|
return server_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct sockaddr_in6 set_address6(struct sockaddr_in6 server_address6)
|
||||||
|
{
|
||||||
|
bzero((char *) &server_address6, sizeof(server_address6));
|
||||||
|
server_address6.sin6_family = AF_INET6;
|
||||||
|
server_address6.sin6_addr = in6addr_any;
|
||||||
|
server_address6.sin6_port = htons((unsigned short)PORT);
|
||||||
|
return server_address6;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void bind_to_port(int listen_socket, struct sockaddr_in server_address)
|
void bind_to_port(int listen_socket, struct sockaddr_in server_address)
|
||||||
{
|
{
|
||||||
if (bind(listen_socket, (struct sockaddr *) &server_address, sizeof(server_address)) < 0)
|
if (bind(listen_socket, (struct sockaddr *) &server_address, sizeof(server_address)) < 0)
|
||||||
error("ERROR while binding to port");
|
error("while binding to port");
|
||||||
if (listen(listen_socket, QUEUE_SIZE) < 0)
|
if (listen(listen_socket, QUEUE_SIZE) < 0)
|
||||||
error("ERROR while starting listening");
|
error("while starting listening");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
void bind_to_port6(int listen_socket, struct sockaddr_in6 server_address6)
|
||||||
|
{
|
||||||
|
if (bind(listen_socket, (struct sockaddr *) &server_address6, sizeof(server_address6)) < 0)
|
||||||
|
error("while binding to port");
|
||||||
|
if (listen(listen_socket, QUEUE_SIZE) < 0)
|
||||||
|
error("while starting listening");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void generate_url(char *buffer, char *slug, size_t slug_length, struct client_data data)
|
void generate_url(char *buffer, char *slug, size_t slug_length, struct client_data data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -271,13 +412,21 @@ void generate_url(char *buffer, char *slug, size_t slug_length, struct client_da
|
|||||||
|
|
||||||
for (i = 0; i <= SLUG_SIZE - 1; i++)
|
for (i = 0; i <= SLUG_SIZE - 1; i++)
|
||||||
{
|
{
|
||||||
|
#if defined(BSD)
|
||||||
|
int symbol_id = arc4random() % strlen(symbols);
|
||||||
|
#else
|
||||||
int symbol_id = rand_r(&time_seed) % strlen(symbols);
|
int symbol_id = rand_r(&time_seed) % strlen(symbols);
|
||||||
|
#endif
|
||||||
slug[i] = symbols[symbol_id];
|
slug[i] = symbols[symbol_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
while (create_directory(slug) == -1)
|
while (create_directory(slug) == -1)
|
||||||
{
|
{
|
||||||
|
#if defined(BSD)
|
||||||
|
int symbol_id = arc4random() % strlen(symbols);
|
||||||
|
#else
|
||||||
int symbol_id = rand_r(&time_seed) % strlen(symbols);
|
int symbol_id = rand_r(&time_seed) % strlen(symbols);
|
||||||
|
#endif
|
||||||
slug[strlen(slug)] = symbols[symbol_id];
|
slug[strlen(slug)] = symbols[symbol_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,16 +435,13 @@ void generate_url(char *buffer, char *slug, size_t slug_length, struct client_da
|
|||||||
|
|
||||||
int create_directory(char *slug)
|
int create_directory(char *slug)
|
||||||
{
|
{
|
||||||
char *directory = malloc(strlen(BASEDIR) + strlen(slug) + 1);
|
char *directory = malloc(strlen(BASEDIR) + strlen(slug) + sizeof(char) + 1);
|
||||||
|
|
||||||
strcpy(directory, BASEDIR);
|
snprintf(directory, strlen(BASEDIR) + strlen(slug) + sizeof(char) + 1, "%s%s%s", BASEDIR, "/", slug);
|
||||||
strcat(directory, slug);
|
|
||||||
|
|
||||||
mkdir(BASEDIR, S_IRWXU | S_IRGRP | S_IROTH | S_IXOTH | S_IXGRP);
|
mkdir(BASEDIR, S_IRWXU | S_IRGRP | S_IROTH | S_IXOTH | S_IXGRP);
|
||||||
int result = mkdir(directory, S_IRWXU | S_IRGRP | S_IROTH | S_IXOTH | S_IXGRP);
|
int result = mkdir(directory, S_IRWXU | S_IRGRP | S_IROTH | S_IXOTH | S_IXGRP);
|
||||||
|
|
||||||
change_owner(directory);
|
|
||||||
|
|
||||||
free(directory);
|
free(directory);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -303,28 +449,20 @@ int create_directory(char *slug)
|
|||||||
|
|
||||||
void save_to_file(char *slug, char *buffer, struct client_data data)
|
void save_to_file(char *slug, char *buffer, struct client_data data)
|
||||||
{
|
{
|
||||||
char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.txt") + 1);
|
char *directory = malloc(strlen(BASEDIR) + strlen(slug) + 11 * sizeof(char) + 1 );
|
||||||
strcpy(directory, BASEDIR);
|
|
||||||
strcat(directory, slug);
|
snprintf(directory, strlen(BASEDIR) + strlen(slug) + 11 * sizeof(char) + 1, "%s%s%s%s", BASEDIR , "/", slug, "/index.txt");
|
||||||
strcat(directory, "/index.txt");
|
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
fp = fopen(directory, "w");
|
fp = fopen(directory, "w");
|
||||||
fprintf(fp, "%s", buffer);
|
fprintf(fp, "%s", buffer);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
change_owner(directory);
|
|
||||||
display_info(data, directory, "");
|
display_info(data, directory, "");
|
||||||
|
|
||||||
free(directory);
|
free(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void change_owner(char *directory)
|
|
||||||
{
|
|
||||||
if ((UID != -1)&&(GID != -1))
|
|
||||||
chown(directory, UID, GID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_uid_gid(char *username)
|
void set_uid_gid(char *username)
|
||||||
{
|
{
|
||||||
struct passwd *userdata = getpwnam(username);
|
struct passwd *userdata = getpwnam(username);
|
||||||
@@ -348,34 +486,67 @@ int check_protocol(char *buffer)
|
|||||||
void set_basedir()
|
void set_basedir()
|
||||||
{
|
{
|
||||||
BASEDIR = getenv("HOME");
|
BASEDIR = getenv("HOME");
|
||||||
strcat(BASEDIR, "/code/");
|
strncat(BASEDIR, "/code", 5 * sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
void startup_message()
|
void startup_message()
|
||||||
{
|
{
|
||||||
display_line();
|
if (DAEMON)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("====================================\n");
|
||||||
printf("Domain name: %s\n", DOMAIN);
|
printf("Domain name: %s\n", DOMAIN);
|
||||||
printf("Saving files to: %s\n", BASEDIR);
|
printf("Saving files to: %s\n", BASEDIR);
|
||||||
printf("Fiche started listening on port %d.\n", PORT);
|
printf("Fiche started listening on port %d.\n", PORT);
|
||||||
display_line();
|
printf("Buffer size set to: %d.\n", BUFSIZE);
|
||||||
|
printf("Slug size set to: %d.\n", SLUG_SIZE);
|
||||||
|
printf("Log file: %s\n", LOG);
|
||||||
|
printf("====================================\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(char *buffer)
|
||||||
|
{
|
||||||
|
printf("Error: %s\n", buffer);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_domain_name() {
|
||||||
|
char b[128];
|
||||||
|
memcpy(b, DOMAIN, sizeof DOMAIN);
|
||||||
|
|
||||||
|
if (HTTPS)
|
||||||
|
snprintf(DOMAIN, sizeof DOMAIN, "%s%s", "https://", b);
|
||||||
|
else
|
||||||
|
snprintf(DOMAIN, sizeof DOMAIN, "%s%s", "http://", b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_parameters(int argc, char **argv)
|
void parse_parameters(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt (argc, argv, "p:b:s:d:o:l:B:u:w:")) != -1)
|
while ((c = getopt (argc, argv, "D6eSp:b:s:d:o:l:B:u:w:")) != -1)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'D':
|
||||||
|
DAEMON = 1;
|
||||||
|
break;
|
||||||
|
case '6':
|
||||||
|
IPv6 = 1;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
snprintf(symbols, sizeof symbols, "%s", "abcdefghijklmnopqrstuvwxyz0123456789-+_=.ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
HTTPS = 1;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
snprintf(DOMAIN, sizeof DOMAIN, "%s%s%s", "http://", optarg, "/");
|
snprintf(DOMAIN, sizeof DOMAIN, "%s%s", optarg, "/");
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
PORT = atoi(optarg);
|
PORT = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
BUFSIZE = atoi(optarg);
|
BUFSIZE = atoi(optarg);
|
||||||
printf("Buffer size set to: %d.\n", BUFSIZE);
|
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
BANFILE = optarg;
|
BANFILE = optarg;
|
||||||
@@ -383,16 +554,12 @@ void parse_parameters(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
SLUG_SIZE = atoi(optarg);
|
SLUG_SIZE = atoi(optarg);
|
||||||
printf("Slug size set to: %d.\n", SLUG_SIZE);
|
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
BASEDIR = optarg;
|
BASEDIR = optarg;
|
||||||
if((BASEDIR[strlen(BASEDIR) - 1]) != '/')
|
|
||||||
strcat(BASEDIR, "/");
|
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
LOG = optarg;
|
LOG = optarg;
|
||||||
printf("Log file: %s\n", LOG);
|
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
set_uid_gid(optarg);
|
set_uid_gid(optarg);
|
||||||
@@ -402,7 +569,7 @@ void parse_parameters(int argc, char **argv)
|
|||||||
load_list(WHITEFILE, 1);
|
load_list(WHITEFILE, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("usage: fiche [-pbsdolBuw].\n");
|
printf("usage: fiche [-D6epbsdSolBuw].\n");
|
||||||
printf(" [-d domain] [-p port] [-s slug_size]\n");
|
printf(" [-d domain] [-p port] [-s slug_size]\n");
|
||||||
printf(" [-o output directory] [-B buffer_size] [-u user name]\n");
|
printf(" [-o output directory] [-B buffer_size] [-u user name]\n");
|
||||||
printf(" [-l log file] [-b banlist] [-w whitelist]\n");
|
printf(" [-l log file] [-b banlist] [-w whitelist]\n");
|
||||||
|
|||||||
38
fiche.h
38
fiche.h
@@ -9,11 +9,15 @@ Live example: http://code.solusipse.net/
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
usage: fiche [-pbsdolBuw].
|
usage: fiche [-DepbsdolBuw].
|
||||||
[-d domain] [-p port] [-s slug size]
|
[-D] [-e] [-d domain] [-p port] [-s slug size]
|
||||||
[-o output directory] [-B buffer size] [-u user name]
|
[-o output directory] [-B buffer size] [-u user name]
|
||||||
[-l log file] [-b banlist] [-w whitelist]
|
[-l log file] [-b banlist] [-w whitelist]
|
||||||
|
|
||||||
|
-D option is for daemonizing fiche
|
||||||
|
|
||||||
|
-e option is for using an extended character set for the URL
|
||||||
|
|
||||||
Compile with Makefile or manually with -O2 and -pthread flags.
|
Compile with Makefile or manually with -O2 and -pthread flags.
|
||||||
To install use `make install` command.
|
To install use `make install` command.
|
||||||
|
|
||||||
@@ -27,6 +31,10 @@ $ cat fiche.c | nc localhost 9999
|
|||||||
#ifndef FICHE_H
|
#ifndef FICHE_H
|
||||||
#define FICHE_H
|
#define FICHE_H
|
||||||
|
|
||||||
|
#ifndef HAVE_INET6
|
||||||
|
#define HAVE_INET6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
@@ -49,19 +57,25 @@ char *BANLIST;
|
|||||||
char *BANFILE;
|
char *BANFILE;
|
||||||
char *WHITEFILE;
|
char *WHITEFILE;
|
||||||
char *WHITELIST;
|
char *WHITELIST;
|
||||||
|
int DAEMON = 0;
|
||||||
|
int HTTPS = 0;
|
||||||
int PORT = 9999;
|
int PORT = 9999;
|
||||||
|
int IPv6 = 0;
|
||||||
int SLUG_SIZE = 4;
|
int SLUG_SIZE = 4;
|
||||||
int BUFSIZE = 32768;
|
int BUFSIZE = 32768;
|
||||||
int QUEUE_SIZE = 500;
|
int QUEUE_SIZE = 500;
|
||||||
char DOMAIN[128] = "http://localhost/";
|
char DOMAIN[128] = "localhost/";
|
||||||
|
char symbols[67] = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
unsigned int time_seed;
|
unsigned int time_seed;
|
||||||
const char *symbols = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
||||||
|
|
||||||
struct thread_arguments
|
struct thread_arguments
|
||||||
{
|
{
|
||||||
int connection_socket;
|
int connection_socket;
|
||||||
struct sockaddr_in client_address;
|
struct sockaddr_in client_address;
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct sockaddr_in6 client_address6;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct client_data
|
struct client_data
|
||||||
@@ -75,27 +89,33 @@ int create_directory(char *slug);
|
|||||||
int check_protocol(char *buffer);
|
int check_protocol(char *buffer);
|
||||||
|
|
||||||
void bind_to_port(int listen_socket, struct sockaddr_in serveraddr);
|
void bind_to_port(int listen_socket, struct sockaddr_in serveraddr);
|
||||||
void display_line(){printf("====================================\n");}
|
#if (HAVE_INET6)
|
||||||
void error(char *error_code){perror(error_code); exit(1);}
|
void bind_to_port6(int listen_socket, struct sockaddr_in6 serveraddr6);
|
||||||
void display_date();
|
#endif
|
||||||
|
void error(char *buffer);
|
||||||
void perform_connection(int listen_socket);
|
void perform_connection(int listen_socket);
|
||||||
void generate_url(char *buffer, char *slug, size_t slug_length, struct client_data data);
|
void generate_url(char *buffer, char *slug, size_t slug_length, struct client_data data);
|
||||||
void save_to_file(char *buffer, char *slug, struct client_data data);
|
void save_to_file(char *buffer, char *slug, struct client_data data);
|
||||||
void display_info(struct client_data data, char *slug, char *message);
|
void display_info(struct client_data data, char *slug, char *message);
|
||||||
void startup_message();
|
void startup_message();
|
||||||
void set_basedir();
|
void set_basedir();
|
||||||
|
void set_domain_name();
|
||||||
void load_list(char *file_path, int type);
|
void load_list(char *file_path, int type);
|
||||||
void parse_parameters(int argc, char **argv);
|
void parse_parameters(int argc, char **argv);
|
||||||
void save_log(char *slug, char *hostaddrp, char *h_name);
|
void save_log(char *slug, char *hostaddrp, char *h_name);
|
||||||
void change_owner(char *directory);
|
|
||||||
void set_uid_gid();
|
void set_uid_gid();
|
||||||
|
|
||||||
char *return_line(){return("\n====================================");}
|
|
||||||
char *check_banlist(char *ip_address);
|
char *check_banlist(char *ip_address);
|
||||||
char *check_whitelist(char *ip_address);
|
char *check_whitelist(char *ip_address);
|
||||||
char *get_date();
|
char *get_date();
|
||||||
|
|
||||||
struct sockaddr_in set_address(struct sockaddr_in serveraddr);
|
struct sockaddr_in set_address(struct sockaddr_in serveraddr);
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct sockaddr_in6 set_address6(struct sockaddr_in6 serveraddr6);
|
||||||
|
#endif
|
||||||
struct client_data get_client_address(struct sockaddr_in client_address);
|
struct client_data get_client_address(struct sockaddr_in client_address);
|
||||||
|
#if (HAVE_INET6)
|
||||||
|
struct client_data get_client_address6(struct sockaddr_in6 client_address6);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user