Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gwsocket as a library #43

Open
kempgc opened this issue Jan 23, 2022 · 7 comments
Open

gwsocket as a library #43

kempgc opened this issue Jan 23, 2022 · 7 comments

Comments

@kempgc
Copy link

kempgc commented Jan 23, 2022

Love the way gwserver currently but wonder if anyone would have time to perhaps create a library (libgwserver.so) which does not include gwserver.c so the core code can be embedded inside another process and I do not have to run the gwserver separately.

@allinurl
Copy link
Owner

It shouldn't be too bad, I'm guessing the work involved would be to get rid of the gwserver.c file. I can look into it, not sure I can do it soon but I can certainly check it out.

Also, I'm thinking you could include those files in your project and work directly with the header files. Probably not as convenient but perhaps a quick solution.

@kempgc
Copy link
Author

kempgc commented Jan 26, 2022

That would be excellent. I took a look at how the current Makefile is generated and decided it would take me too long to get up to speed on what was going on. Yes this would remove the need for gwserver.c however most of the code would be move across in particular the callbacks to support strict mode, parsing of parameters would not be needed. My current plan is to write a simple makefile which will create a libgwsocket.so.

If its ok with you I would like to update the code to remove many of the issues that Coverity (https://www.synopsys.com/software-integrity/security-testing.html) is finding, mainly NULL pointer checking etc. This is a server so security is important. Happy to push changes and once I have completed along with my code that demonstrates how to use if you wish.

@allinurl
Copy link
Owner

That would be awesome. Thanks!

@imatasic
Copy link

would this be something that could be used with apache web server?

@allinurl
Copy link
Owner

@imatasic what are you trying to achieve?

@imatasic
Copy link

@allinurl Well, I am struggling to get the boilerplate configuration for apache to proxy the websocket properly. Sometimes I have to use both proxypass and rewrite directive, sometimes only proxypass works and i think this might impact the performance.
not to mention it takes up an available connection from apache, so I have to increase that number as well.

example:

...
ServerName site.example.com
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
SSLProxyEngine On

ProxyPass /wss  wss://192.168.14.20:8080/
ProxyPassReverse /wss wss://192.168.14.20:8080/
...
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* wss://192.168.14.20:8080%{REQUEST_URI} [P]
...

This is the only way i found that I can access the websocket from both inside the network, and from the internet when I access https://site.example.com.

Maybe I am doing this completely wrong.
Is there a better way to do this with nginx?

@allinurl
Copy link
Owner

@imatasic if I understand correctly, gwsocket could help you achieve that. goaccess uses gwsocket on the back-end. There are some guides on how to get this done with apache, take a look at this guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants