zerowidth / camper_van

A Campfire to IRC bridge
MIT License
129 stars 25 forks source link

Paste URLs have duplicate hosts #26

Closed yorickpeterse closed 11 years ago

yorickpeterse commented 11 years ago

Whenever somebody pastes something into Campfire the URL for said paste contains the Campfire host twice.

For example, if Campfire is running at cookies.campfirenow.com then the resulting URL will be something along the lines of cookies.campfirenow.com.campfirenow.com/room/X/paste/Y.

This issue occurs on camper_van 0.0.6. Although I updated to 0.0.7 I haven't had people paste anything in yet so I can't confirm/deny whether the issue is still the case on this version. There however don't seem to be any commits addressing this issue between the two mentioned versions.

zerowidth commented 11 years ago

No one's mentioned this yet.

I'm building that paste url entirely by hand: https://github.com/aniero/camper_van/blob/master/lib/camper_van/channel.rb#L311-L321

Could you show me what camper_van is receiving when it gets a pasted message? Perhaps the campfire API has changed something. (--log-level=debug please)

yorickpeterse commented 11 years ago

This is logged whenever somebody pastes something in Campfire:

2013-02-20T16:24:11+00:00 stewie campfire[18576]: 2013-02-20 16:24:11 18576 DEBUG CamperVan : irc <- :hubot!hubot@campfire JOIN #backchannel
2013-02-20T16:24:16+00:00 stewie campfire[18576]: 2013-02-20 16:24:16 18576 DEBUG CamperVan : irc -> PING 127.0.0.1
2013-02-20T16:24:16+00:00 stewie campfire[18576]: 2013-02-20 16:24:16 18576 DEBUG CamperVan : irc <- :camper_van PONG 127.0.0.1
2013-02-20T16:24:29+00:00 stewie campfire[18576]: 2013-02-20 16:24:29 18576 DEBUG CamperVan : irc <- :hubot!hubot@campfire PRIVMSG #backchannel :>   start_date: (months) ->
2013-02-20T16:24:29+00:00 stewie campfire[18576]: 2013-02-20 16:24:29 18576 DEBUG CamperVan : irc <- :hubot!hubot@campfire PRIVMSG #backchannel :>     start  = new Date()
2013-02-20T16:24:29+00:00 stewie campfire[18576]: 2013-02-20 16:24:29 18576 DEBUG CamperVan : irc <- :hubot!hubot@campfire PRIVMSG #backchannel :>     months = months - 1 # Javascript months range from 0 to 11.
2013-02-20T16:24:29+00:00 stewie campfire[18576]: 2013-02-20 16:24:29 18576 DEBUG CamperVan : irc <- :hubot!hubot@campfire PRIVMSG #backchannel :> more: https://REDACTED.campfirenow.com.campfirenow.com/room/REDACTED/paste/REDACTED

I trimmed/redacted non relevant and private information.

zerowidth commented 11 years ago

That subdomain is coming from the irc PASS command you send when first connecting. Are you using the whole domain there, i.e. REDACTED.campfirenow.com, rather than just REDACTED ? It's possible that campfire is allowing that to work if it's grabbing the first piece of the subdomain you connect with, e.g. domain.split('.').first

yorickpeterse commented 11 years ago

I'm currently using the full domain name instead of only using the sub domain. I'll give it a try to see how things work when only using the subdomain.

yorickpeterse commented 11 years ago

After having tested this for a bit I can confirm that this can be resolved by only using the sub domain in your IRC client's PASS command. In other words, use "foo" instead of "foo.campfirenow.com".

zerowidth commented 11 years ago

Thanks for checking. I'll update the documentation, but I can also detect that subdomain (split(".").first) in the code.

yorickpeterse commented 11 years ago

:+1: