BetterCorp / cloudflarewarp

MIT License
79 stars 6 forks source link

Plugin get panic every time when websocket connection close. #14

Closed ncwhale closed 1 year ago

ncwhale commented 1 year ago

What happened:

When a websocket connection is closed by browser(client), an error message comes from this plugin.

Error message:

traefik-traefik-1  | time="2022-09-23T02:22:46Z" level=error msg="plugins-storage/sources/gop-2426158314/src/github.com/BetterCorp/cloudflarewarp/cloudflarewarp.go:88:17: panic" plugin=plugin-cloudflarewarp module=github.com/BetterCorp/cloudflarewarp
traefik-traefik-1  | time="2022-09-23T02:29:58Z" level=error msg="plugins-storage/sources/gop-2426158314/src/github.com/BetterCorp/cloudflarewarp/cloudflarewarp.go:88:17: panic" module=github.com/BetterCorp/cloudflarewarp plugin=plugin-cloudflarewarp

my env: traefik v2.8 , using docker image from hub.

plugxin config:

experimental:
  plugins:
    cloudflarewarp:
      modulename: github.com/BetterCorp/cloudflarewarp
      version: v1.3.1

middleware config:

http:
  middlewares:
    cloudflareip:
      plugin:
        cloudflarewarp:
          disableDefault: "true"
          trustip:
            - "173.245.48.0/20"
            - "103.21.244.0/22"
            - "103.22.200.0/22"
            - "103.31.4.0/22"
            - "141.101.64.0/18"
            - "108.162.192.0/18"
            - "190.93.240.0/20"
            - "188.114.96.0/20"
            - "197.234.240.0/22"
            - "198.41.128.0/17"
            - "162.158.0.0/15"
            - "104.16.0.0/13"
            - "104.24.0.0/14"
            - "172.64.0.0/13"
            - "131.0.72.0/22"
            - "2400:cb00::/32"
            - "2606:4700::/32"
            - "2803:f800::/32"
            - "2405:b500::/32"
            - "2405:8100::/32"
            - "2a06:98c0::/29"
            - "2c0f:f248::/32"
mrinc commented 1 year ago

Ref: https://github.com/BetterCorp/cloudflarewarp/blob/master/cloudflarewarp.go#L88

@ncwhale What is the WS server/client platform you are using?

mrinc commented 1 year ago

Try changing the config to match correctly -

http:
  middlewares:  
    cloudflareip:  
      plugin:  
        cloudflarewarp:  
          disableDefault: false  

If you have specific additional IPs other than CF, then define trustip.

Added some extra handling... not sure it'll help, but anyway let me know if the above config still has the issues and info about your setup.

mrinc commented 1 year ago

v1.3.3 - released, try that with the above ^

mrinc commented 1 year ago

@ncwhale re-open this if it's still an issue

ncwhale commented 1 year ago

Well, I updated traefik & this plugin to v1.3.3 , but still got this panic every time the ws is disconnected.

traefik  | time="2022-10-06T14:04:42Z" level=error msg="plugins-storage/sources/gop-215151865/src/github.com/BetterCorp/cloudflarewarp/cloudflarewarp.go:89:17: panic" plugin=plugin-cloudflarewarp module=github.com/BetterCorp/cloudflarewarp
traefik  | time="2022-10-06T14:04:46Z" level=error msg="plugins-storage/sources/gop-215151865/src/github.com/BetterCorp/cloudflarewarp/cloudflarewarp.go:89:17: panic" plugin=plugin-cloudflarewarp module=github.com/BetterCorp/cloudflarewarp
traefik  | time="2022-10-06T14:04:51Z" level=error msg="plugins-storage/sources/gop-215151865/src/github.com/BetterCorp/cloudflarewarp/cloudflarewarp.go:89:17: panic" plugin=plugin-cloudflarewarp module=github.com/BetterCorp/cloudflarewarp

How to reproduce this bug:

  1. Create any service with WebSocket auto connected and proxy by traefik;
  2. Add this plugin as middleware for cloudflare ip reverse;
  3. Add this site proxy by cloudflare;
  4. Open the service through cloudflare proxy dna name;
  5. Just Refresh the page which will case the WS disconnect, and the panic happens.
ncwhale commented 1 year ago

I cannot reopen this issue so I'll create a new one for this bug.