40 次代码提交 d999eb46e9 ... 3931278a92

作者 SHA1 备注 提交日期
  Lisa Marie 3931278a92 commiting whats here 8 年之前
  Lisa Marie 712192367c moved code to protocol and legacy parser 9 年之前
  Lisa Marie 83eafe4570 cleaned up websockets, got basic chat into proto 9 年之前
  Lisa Marie 52c0b4624c added webui_proto 9 年之前
  Lisa Marie 602c3a81cd stable websockets 9 年之前
  Lisa Marie 4d01d0dfa4 stable version with input/output queue 9 年之前
  Lisa Marie 97834f4ce4 almost ready for parser, got working send() 9 年之前
  Lisa Marie b1ed4df352 added proof of concept ping/pong cusotm commands 9 年之前
  Lisa Marie 870a778f0c added proof of concept ping/pong cusotm commands 9 年之前
  Lisa Marie f8c2403100 cleaned up recv code, more proof of concept work 9 年之前
  Lisa Marie fce3694198 added proof of concept ping/pong cusotm commands 9 年之前
  Lisa Marie 1bf2351680 added missing free() 9 年之前
  Lisa Marie 60e7099b78 fixed typo 9 年之前
  Lisa Marie 355732abc6 first successful unmask 9 年之前
  Lisa Marie ea5c6dc7ce moved thread cleanupcode, added a usleep() for now 9 年之前
  Lisa Marie 5dc9819282 added gracefulsocket death 9 年之前
  Lisa Marie 0c7a2fe3f7 first attempt at threading websockets 9 年之前
  Lisa Marie cc0d07c8e0 removed a dud 9 年之前
  Lisa Marie 698fdb36e2 added missing dirs for new coders 9 年之前
  Lisa Marie 6efbd7b01c removed buffer trunkcates 9 年之前
  Lisa Marie 9321a64acf current websockets work, and clenaup 9 年之前
  Lisa Marie ee192d902d removed more cruft 9 年之前
  Lisa Marie 322eab573f cleaned up code, moved parsing to handlewebsockets only 9 年之前
  Joshua Drake e49fc624bc Merge branch 'websockets' of notabug.org:sleepyhackers/sleepermud into websockets 9 年之前
  Joshua Drake a3db76d30a Destroy websocket event in unload 9 年之前
  Lisa Marie ee15b3271c removed more cruft 9 年之前
  Lisa Marie 4ccc5e4bae cleaned up socket send code, removed debug prints 9 年之前
  Lisa Marie e8e72a6372 fixed handshake, added premature optimizations 9 年之前
  Lisa Marie 85aa846caf Revert "Revert "moved to thread safe strtok_r()"" 9 年之前
  Lisa Marie ccb456c9fa Revert "moved to thread safe strtok_r()" 9 年之前
  Lisa Marie 6365ea8a3f moved to thread safe strtok_r() 9 年之前
  Lisa Marie 1f8aa918ef closes connections now 9 年之前
  Lisa Marie 6032ce84ab fixed it so websockets reload 9 年之前
  Lisa Marie 30b2a35b2a finished handshake 9 年之前
  Joshua Drake 7eaec3e793 Work on websockets 9 年之前
  Joshua Drake 77cde90eb7 Compile libb64 into module 9 年之前
  Joshua Drake 8c6069b28b Switch b64 lib, minor Makefile modifications 9 年之前
  Lisa Marie eb15e9d0da cleaned up tree, commited what i got 9 年之前
  Lisa Marie f7f7144778 moved back to uid 9 年之前
  Lisa Marie bf7b9bbf18 added websockets 9 年之前

+ 2 - 0
.gitignore

@@ -9,3 +9,5 @@ lib/world/world
 core
 lib/
 log/
+\#*
+.\#*

+ 1 - 0
lib/accounts/.gitignore

@@ -0,0 +1 @@
+#add this dir

+ 1 - 0
lib/modules/.gitignore

@@ -0,0 +1 @@
+#add this dir

+ 1 - 0
lib/players/.gitignore

@@ -0,0 +1 @@
+#add this dir

+ 3 - 3
src/Makefile

@@ -21,7 +21,7 @@ PROJECT := $(shell echo $(BINARY) | tr A-Z a-z)
 MODULE_DIR := modules
 
 # Directories of modules using the 2.0 system
-MODULES2 := dice party stats
+MODULES2 := dice party stats websockets webui_proto webui_mud
 
 # Path to python config utility
 PYTHON_CONFIG := python2.7-config
@@ -47,7 +47,7 @@ C_FLAGS := -Wall -g -ggdb -fPIC -I${INCLUDE_DIR} -O2 -pipe -march=native
 C_FLAGS := ${C_FLAGS} ${shell ${PYTHON_CONFIG} --cflags} -Wno-strict-prototypes -Wno-unused-value -Wno-unused-but-set-variable 
 
 # Libraries and link flags
-LIBS := -lz -lpthread -lcrypt -ldl -Wl,--export-dynamic
+LIBS := -lz -lpthread -lcrypt -lhttp_parser -ldl -Wl,--export-dynamic
 LIBS += ${shell ${PYTHON_CONFIG} --ldflags}
 
 # SleeperMUD core source files
@@ -100,7 +100,7 @@ ${OBJ_DIR}/%.o: ${SRC_DIR}/%.c
 	@mv ${notdir $@} ${OBJ_DIR}
 
 modules:
-	@${foreach module,${MODULES2},/bin/bash -c "cd ${MODULE_DIR}/${module} && make && cd ..";}
+	@${foreach module,${MODULES2},/bin/bash -c "cd ${MODULE_DIR}/${module} && CC=\"${CC}\" CFLAGS=\"${CFLAGS}\" LIBS=\"${LIBS}\" make && cd ..";}
 
 #For compiling as module
 as-module: ${DEPS} ${O_FILES}

+ 3 - 2
src/modules/Makefile.module

@@ -3,8 +3,9 @@ OBJS := ${patsubst %.c,%.o,${filter %.c, ${SRC}}}
 OUT := ${ROOT}/lib/modules/${OUT}
 
 %.o: %.c
-	gcc -I${ROOT}/include -c -fpic $<
+	${CC} ${CFLAGS} -I${ROOT}/src/include -c -fpic $<
 all: ${OBJS}
-	gcc -shared -o ${OUT} *.o
+	${CC} ${CFLAGS} -shared -o ${OUT} *.o ${LIBS}
+	rm *.o
 syms:
 	@objdump -e ${OUT} -TS

+ 7 - 0
src/modules/websockets/Makefile

@@ -0,0 +1,7 @@
+SRC   := websockets.c wsutil.c cdecode.c cencode.c
+OUT   := websockets.so
+LIBS  := -lssl
+CFLAGS += -I/usr/include/openssl -g
+# * End config * #
+
+include ../Makefile.module

+ 88 - 0
src/modules/websockets/cdecode.c

@@ -0,0 +1,88 @@
+/*
+cdecoder.c - c source to a base64 decoding algorithm implementation
+
+This is part of the libb64 project, and has been placed in the public domain.
+For details, see http://sourceforge.net/projects/libb64
+*/
+
+#include "cdecode.h"
+
+int base64_decode_value(char value_in)
+{
+	static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
+	static const char decoding_size = sizeof(decoding);
+	value_in -= 43;
+	if (value_in < 0 || value_in > decoding_size) return -1;
+	return decoding[(int)value_in];
+}
+
+void base64_init_decodestate(base64_decodestate* state_in)
+{
+	state_in->step = step_a;
+	state_in->plainchar = 0;
+}
+
+int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in)
+{
+	const char* codechar = code_in;
+	char* plainchar = plaintext_out;
+	char fragment;
+	
+	*plainchar = state_in->plainchar;
+	
+	switch (state_in->step)
+	{
+		while (1)
+		{
+	case step_a:
+			do {
+				if (codechar == code_in+length_in)
+				{
+					state_in->step = step_a;
+					state_in->plainchar = *plainchar;
+					return plainchar - plaintext_out;
+				}
+				fragment = (char)base64_decode_value(*codechar++);
+			} while (fragment < 0);
+			*plainchar    = (fragment & 0x03f) << 2;
+	case step_b:
+			do {
+				if (codechar == code_in+length_in)
+				{
+					state_in->step = step_b;
+					state_in->plainchar = *plainchar;
+					return plainchar - plaintext_out;
+				}
+				fragment = (char)base64_decode_value(*codechar++);
+			} while (fragment < 0);
+			*plainchar++ |= (fragment & 0x030) >> 4;
+			*plainchar    = (fragment & 0x00f) << 4;
+	case step_c:
+			do {
+				if (codechar == code_in+length_in)
+				{
+					state_in->step = step_c;
+					state_in->plainchar = *plainchar;
+					return plainchar - plaintext_out;
+				}
+				fragment = (char)base64_decode_value(*codechar++);
+			} while (fragment < 0);
+			*plainchar++ |= (fragment & 0x03c) >> 2;
+			*plainchar    = (fragment & 0x003) << 6;
+	case step_d:
+			do {
+				if (codechar == code_in+length_in)
+				{
+					state_in->step = step_d;
+					state_in->plainchar = *plainchar;
+					return plainchar - plaintext_out;
+				}
+				fragment = (char)base64_decode_value(*codechar++);
+			} while (fragment < 0);
+			*plainchar++   |= (fragment & 0x03f);
+		}
+	}
+	/* control should not reach here */
+	return plainchar - plaintext_out;
+}
+

+ 28 - 0
src/modules/websockets/cdecode.h

@@ -0,0 +1,28 @@
+/*
+cdecode.h - c header for a base64 decoding algorithm
+
+This is part of the libb64 project, and has been placed in the public domain.
+For details, see http://sourceforge.net/projects/libb64
+*/
+
+#ifndef BASE64_CDECODE_H
+#define BASE64_CDECODE_H
+
+typedef enum
+{
+	step_a, step_b, step_c, step_d
+} base64_decodestep;
+
+typedef struct
+{
+	base64_decodestep step;
+	char plainchar;
+} base64_decodestate;
+
+void base64_init_decodestate(base64_decodestate* state_in);
+
+int base64_decode_value(char value_in);
+
+int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in);
+
+#endif /* BASE64_CDECODE_H */

+ 0 - 0
src/modules/websockets/cencode.c


部分文件因为文件数量过多而无法显示