catalinux / Conn (public) (License: LGPLv2) (since 2016-03-01) (hash sha1)
Net library for easy building ipv4/ipv6 network daemons/clients
List of commits:
Subject Hash Author Date (UTC)
More tweaks to wsdemo 56173807662daf36b36907d98bde751749c91075 Catalin(ux) M. BOIE 2018-04-16 18:08:18
Added a callback for worker start 32a05f401d5258f06af9db15a00a615859961cc2 Catalin(ux) M. BOIE 2018-04-16 18:07:55
wsdemo improvements 3eb3efd007fc9240ea39fabcdb4729d1367ebad2 Catalin(ux) M. BOIE 2018-04-13 22:47:24
wsdemo added 2baae01f2409496f990b6d673013b66286f0a5af Catalin(ux) M. BOIE 2018-04-02 21:41:40
Various small stuff 0c551268be734dd68a59426315abfc6ef776c60a Catalin(ux) M. BOIE 2018-04-02 21:40:49
More debugging for websocket parsing 66ccde632b280f1aa450610e6b671464b7e56451 Catalin(ux) M. BOIE 2018-04-02 21:39:23
Raise to 4096 to buffer for logging a59dee1fdfe087ff13e4c7012fe29f8da99ad75c Catalin(ux) M. BOIE 2018-04-02 21:38:11
Bump version 9b635cebfffdd6971eefef0ebad395e21684bb8a Catalin(ux) M. BOIE 2018-01-13 18:07:12
Added some more compile flags and websocket1 helper files. fce47295946106956fb70da77244d77ffca09423 Catalin(ux) M. BOIE 2018-01-13 18:03:46
Lots of changes everywhere 91b9113e8f92db07c079c005273683f2e868910c Catalin(ux) M. BOIE 2018-01-12 19:06:04
Require openssl (for websocket) b4b34eb88f38bfd421187da76611cc54476d7309 Catalin(ux) M. BOIE 2017-12-30 23:44:50
Very important fixes 01e33f06a5cdc52fb3795158fd838fcca7055dda Catalin(ux) M. BOIE 2017-12-30 23:39:17
Bump version to 1.0.37 54e8f3bcaf7f7e096c454563039a545a4abb1bf0 Catalin(ux) M. BOIE 2017-12-30 22:13:12
Lots of small fixes 4894de0472e571b8c78294de527bf70089096545 Catalin(ux) M. BOIE 2017-12-30 22:11:09
Checkpoint b6bf45330f046da40d762b6fd10d1bb97bc40036 Catalin(ux) M. BOIE 2017-12-28 00:13:09
Fixed libConn*.so instalation. df1bef9190d30dd11fcd150b41810ce18278b74f Catalin(ux) M. BOIE 2015-04-25 14:43:37
libConn1.so was not included in spec file. dd99625a7fb70d66fa5a91371fb4d2eaf7a4f23d Catalin(ux) M. BOIE 2015-04-25 14:39:32
Small fixes for build system. ab12cbbe149933cbf1b9a9900be1a45d63ee0b29 Catalin(ux) M. BOIE 2015-04-25 14:17:14
Build fixes e7521468199d4da53461fb0c1ffa08e1913c1e9f Catalin(ux) M. BOIE 2015-04-24 19:18:42
Checkpoint before switching to processes not threads de43b387557dde215ab1210838d396e7e7b22c4f Catalin(ux) M. BOIE 2015-01-14 04:13:00
Commit 56173807662daf36b36907d98bde751749c91075 - More tweaks to wsdemo
Author: Catalin(ux) M. BOIE
Author date (UTC): 2018-04-16 18:08
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2018-04-16 18:08
Parent(s): 32a05f401d5258f06af9db15a00a615859961cc2
Signing key:
Tree: 83f67856f266e4f2fe686ebb76e1ab497fb79526
File Lines added Lines deleted
examples/Makefile 1 1
examples/wsdemo.c 59 6
File examples/Makefile changed (mode: 100644) (index 6574257..ca0671e)
... ... websocket1: websocket1.c $(DEPS)
66 66 gcc $(CFLAGS) -I/usr/include/json-c $(INCS) $@.c -o $@ $(LIBS) -ljson-c gcc $(CFLAGS) -I/usr/include/json-c $(INCS) $@.c -o $@ $(LIBS) -ljson-c
67 67
68 68 wsdemo: wsdemo.c $(DEPS) wsdemo: wsdemo.c $(DEPS)
69 gcc $(CFLAGS) -I/usr/include/json-c $(INCS) $@.c -o $@ $(LIBS) -ljson-c
69 gcc $(CFLAGS) -I/usr/include/json-c $(INCS) $@.c -o $@ $(LIBS) -ljson-c -lcap
70 70
71 71 ma: ma.c ma: ma.c
72 72 gcc $(CFLAGS) $(INCS) $@.c -o $@ -lpthread gcc $(CFLAGS) $(INCS) $@.c -o $@ -lpthread
File examples/wsdemo.c changed (mode: 100644) (index 94e11ed..8078778)
13 13 #include <sys/ioctl.h> #include <sys/ioctl.h>
14 14 #include <time.h> #include <time.h>
15 15 #include <stdarg.h> #include <stdarg.h>
16 #include <sys/capability.h>
16 17
17 18 #include <Conn.h> #include <Conn.h>
18 19 #include <json.h> #include <json.h>
 
... ... static const char main_screen[] =
727 728 "</div>\n\n" "</div>\n\n"
728 729 "" ""
729 730 "<div class=\"gem\" width=\"120px\">\n" "<div class=\"gem\" width=\"120px\">\n"
730 "Progress bar 2 (svg)\n"
731 "Progress bar 2 (SVG)\n"
731 732 "<svg height=\"20\" width=\"110\" style=\"border: 1px solid black\">\n" "<svg height=\"20\" width=\"110\" style=\"border: 1px solid black\">\n"
732 733 " <defs>\n" " <defs>\n"
733 734 " <linearGradient id=\"per2_gra1\" gradientTransform=\"rotate(90)\">\n" " <linearGradient id=\"per2_gra1\" gradientTransform=\"rotate(90)\">\n"
 
... ... static const char main_screen[] =
751 752 " available width, but no more than 100px; previous values are pushed by the server.</div>\n" " available width, but no more than 100px; previous values are pushed by the server.</div>\n"
752 753 "</div>\n\n" "</div>\n\n"
753 754 "" ""
754 "<div class=\"gem\" TODOwidth=\"420px\">\n"
755 "<div class=\"gem\">\n"
755 756 "Bandwidth (SVG)\n" "Bandwidth (SVG)\n"
756 757 "<svg id=\"band1_container\" height=\"102\" width=\"100\" style=\"border: 1px solid green\">\n" "<svg id=\"band1_container\" height=\"102\" width=\"100\" style=\"border: 1px solid green\">\n"
757 758 " <g id=\"band1\"></g>\n" " <g id=\"band1\"></g>\n"
 
... ... static void ws1(struct Conn *C)
1022 1023 goto again; goto again;
1023 1024 } }
1024 1025
1026 /*
1027 * Drop privileges
1028 * returns -1 on error
1029 */
1030 static void drop_privileges(struct Conn *C)
1031 {
1032 int ret, err;
1033 cap_t caps;
1034
1035 chdir("/");
1036
1037 err = -1;
1038 while (1) {
1039 caps = cap_get_proc();
1040 if (!caps) {
1041 Log(0, "Cannot obtain caps: %s!\n", strerror(errno));
1042 break;
1043 }
1044
1045 ret = cap_clear(caps);
1046 if (ret == -1) {
1047 Log(0, "Cannot clear caps: %s!\n", strerror(errno));
1048 break;
1049 }
1050
1051 ret = cap_set_proc(caps);
1052 if (ret == -1) {
1053 Log(0, "Cannot set caps: %s!\n", strerror(errno));
1054 break;
1055 }
1056
1057 err = 0;
1058 break;
1059 }
1060 if (caps)
1061 cap_free(caps);
1062
1063 if (err != 0)
1064 Conn_close(C);
1065 }
1066
1025 1067 int main(void) int main(void)
1026 1068 { {
1027 int ret;
1069 int ret, fd;
1028 1070 struct Conn *C; struct Conn *C;
1029 char *stats;
1071 char *stats, path[256];
1072 struct timeval now;
1073 struct tm tm;
1030 1074
1031 setlinebuf(stdout);
1075 gettimeofday(&now, NULL);
1076 localtime_r(&now.tv_sec, &tm);
1077 snprintf(path, sizeof(path), "/var/log/Conn/wsdemo-%04d-%02d-%02d.log",
1078 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
1079 fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0600);
1080 if (fd == -1) {
1081 fprintf(stderr, "Cannot open log file: %s!\n", strerror(errno));
1082 return 1;
1083 }
1032 1084
1033 Conn_debug(2, debug);
1085 Conn_debug(fd, debug);
1034 1086
1035 1087 ret = Conn_init(0); ret = Conn_init(0);
1036 1088 if (ret == -1) { if (ret == -1) {
 
... ... int main(void)
1074 1126
1075 1127 Conn_set_cb(C, CONN_CB_ACCEPT, accept_cb); Conn_set_cb(C, CONN_CB_ACCEPT, accept_cb);
1076 1128 Conn_set_cb(C, CONN_CB_CLOSE, close_cb); Conn_set_cb(C, CONN_CB_CLOSE, close_cb);
1129 Conn_set_cb(C, CONN_CB_WORKER_START, drop_privileges);
1077 1130
1078 1131 ret = Conn_commit(C); ret = Conn_commit(C);
1079 1132 if (ret != 0) { if (ret != 0) {
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/Conn

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/Conn

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/Conn

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main