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

[BUG] - Proxy fails to start if there is an improper configuration file #120

Closed
RickoT opened this issue Apr 6, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@RickoT
Copy link

RickoT commented Apr 6, 2024

Describe the bug
If a misconfiguration happens, it crashes and does not recover
(I did not think to save the file that had the issue before I deleted it)

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'create proxy rules
  2. Add a new proxy that is configured incorrectly

Expected behavior
Either it will recognize it is a bad config (if possible)
Or when restarting it will notify of an error but continue loading

Host Environment (please complete the following information):

  • Arch: AMD64
  • Device: Docker
  • OS: Debian 12.4

Additional context
Required fix was to delete the file for the proxy host i misconfigured
This is the error that occurs on startup with an invalid configuration

panic: runtime error: slice bounds out of range [-1:]
goroutine 31 [running]:
imuslab.com/zoraxy/mod/dynamicproxy.(*Router).PrepareProxyRoute(0xc0001aaa00?, 0x19d?)
/opt/zoraxy/source/mod/dynamicproxy/router.go:22 +0x3fe
main.LoadReverseProxyConfig({0xc0036943c0?, 0x15?})
/opt/zoraxy/source/config.go:72 +0xbf
main.ReverseProxtInit()
/opt/zoraxy/source/reverseproxy.go:112 +0x82f
main.main.func1()
/opt/zoraxy/source/main.go:163 +0xf
created by main.main in goroutine 1
/opt/zoraxy/source/main.go:162 +0x231

@RickoT RickoT added the bug Something isn't working label Apr 6, 2024
@RickoT RickoT changed the title [BUG] [BUG] - Proxy fails to start if there is an improper configuration file Apr 6, 2024
@tobychui
Copy link
Owner

tobychui commented Apr 6, 2024

@RickoT
Thanks for the issue.
This seems more like a feature request (check for improper config file from file) than a bug. Improper config file can cause crash which makes logical sense, and there are cleaning and validation code in place when you set it up using the web interface so this seems like an additional feature to me.

The line that caused such panic is from here

if domain[len(domain)-1:] == "/" { <-- This line
	domain = domain[:len(domain)-1]
}
endpoint.Domain = domain

You leave the domain field empty or what? Can you show me your improper config file?

tobychui added a commit that referenced this issue Apr 14, 2024
+ Fixed zeroSSL bug (said by @yeungalan ) #45
+ Fixed manual renew button bug
+ Seperated geodb module with access controller
+ Added per hosts access control (experimental) #69
+ Fixed basic auth not working on TLS bypass mode bug
+ Fixed empty domain crash bug #120
@tobychui
Copy link
Owner

As the author of this issue is not responding, I will assume the error was come from empty string used in the domain field and has been fixed by checking if the field is empty. Closing this in v3.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants