The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-09-26

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:02 stryx` joined #mojo
00:05 Grinnz sri: ubuntu is pushing snappy, fedora is pushing flatpak... so we'll see what happens
00:06 Grinnz both are trying to support both variants so at least there shouldnt be any miscompatibility there
00:10 stefan What about checking X-Forwarded-Proto when determining is_secure?  I want to  redirect to https if !req->is_secure, but when behind an ssl proxy is_secure doesn't think the request was https when it was.  https://github.com/s1037989/mojo/commit/285ffe0ab57f0d4f4238af92a9090afd13aaad95
00:16 sri stefan: X-Forwarded-Proto is already supported
00:17 sri your patch actually adds a security hole
00:18 stefan :O
00:19 stefan I have a before_dispatch hook and $c->req->headers->header('X-Forwarded-Proto') is 'https' but $c->req->is_secure is false.  I would expect it to be true, yes?
00:20 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Hypnotoad
00:21 stefan What about when the server is morbo?  Just set the env variable?
00:21 sri nobody deploys morbo behind a reverse proxy
00:21 Grinnz uhhh
00:21 sri that would be the silliest setup ever ;p
00:21 stefan I do!  My development environment is at Cloud 9.  http://c9.io
00:21 Grinnz we do :P but i just set MOJO_REVERSE_PROXY=1
00:22 sri :O
00:22 Grinnz we have to have nginx set up the same on dev and prod
00:22 Grinnz apache rather
00:22 Grinnz i wish it was nginx :P
00:22 sri ¯\_(ツ)_/¯
00:26 jberger hehe, I'm actually doing it right now :-P only for testing a new project but yeah, MOJO_REVERSE_PROXY=1 works too
00:27 sri oh come on...
00:27 jberger I need a public IP for post data from my phone to come to
00:27 sri https://cdn.meme.am/instances/500x/57272070.jpg
00:28 jberger but I don't think that this should be encouraged, having an env var is plenty
00:28 jberger ha
00:29 Grinnz in our case, it's partially because we're currently sharing port 443 with another project using apache, and partially because we need apache to handle SNI
00:31 Grinnz we tried individual ports once, it just wasn't as good as having subdomains
00:32 jberger I'm just too lazy to setup NAT at my house, easier to test from my public facing personal server which already has nginx going for my convos install
00:32 jberger and virtual hosting from that
00:33 stryx` joined #mojo
00:45 stryx` joined #mojo
00:46 irqq_ joined #mojo
01:10 zivester joined #mojo
01:12 stryx`_ joined #mojo
01:29 stryx` joined #mojo
01:31 Janos joined #mojo
01:36 stryx` joined #mojo
01:46 stryx` joined #mojo
01:51 stryx` joined #mojo
02:09 noganex_ joined #mojo
02:24 Janos joined #mojo
02:33 jberger It's really funny this happened tonight
02:33 jberger I'm not sure if I've done that before today
03:43 cpan_mojo Mojolicious-Plugin-SecureOnly-0.02 by SADAMS https://metacpan.org/release/SADAMS/Mojolicious-Plugin-SecureOnly-0.02
03:45 PryMar56 joined #mojo
04:03 inokenty-w joined #mojo
04:16 Grinnz neat https://v1.metacpan.org/pod/release/IOANR/Linux-Systemd-1.162700/lib/Linux/Systemd/Daemon.pm
04:16 Grinnz i feel like the need for an API for sd_notify came up at some point but dont remember
04:17 Grinnz oh right, it's needed if you want to use systemd's watchdog
04:19 preaction so it is true: systemd wants to be part of every single process on my machine
04:25 Grinnz i mean, there's other watchdogs you can use
04:37 zivester joined #mojo
04:47 Janos joined #mojo
05:41 Janos joined #mojo
05:55 dod joined #mojo
05:59 polettix joined #mojo
06:00 dod joined #mojo
06:17 mbudde joined #mojo
06:24 dod joined #mojo
06:54 salva joined #mojo
06:58 trone joined #mojo
07:10 AndrewIsh joined #mojo
07:34 FY joined #mojo
07:34 FY Hi All
07:38 abra joined #mojo
07:43 Vandal50506 joined #mojo
07:46 FY left #mojo
07:52 abra_ joined #mojo
08:18 osfabibisi joined #mojo
08:19 rshadow joined #mojo
08:22 rshadow joined #mojo
08:31 Janos joined #mojo
09:09 Janos joined #mojo
09:55 niclan joined #mojo
09:55 niclan re-foo
09:56 niclan how do i disable this? # Inactivity timeout
09:56 niclan for debugging
09:57 batman niclan: in client or server?
09:57 niclan test program
09:57 niclan testing server side mojo
09:58 batman $c->inactivity_timeout($seconds);
09:58 niclan I need more time in the debugger...
09:58 batman niclan: https://metacpan.org/pod/Mojolicious::Plugin::DefaultHelpers#inactivity_timeout
10:04 niclan ... on the connection
10:12 niclan they don't really like infinite timeouts
10:12 niclan neither 0 or -1
10:16 Janos joined #mojo
10:28 sri if 0 doesn't work that would be a bug
10:29 pink_mist what about ->inactivity_timeout(Inf); ? :) or will that break things? :P
11:13 Lee joined #mojo
11:14 tchaves joined #mojo
11:17 tchaves joined #mojo
11:32 janl 0 does not work
11:32 janl I had to resort to 999999
11:33 janl $Mojolicious::VERSION = '5.82'
11:49 Janos joined #mojo
11:51 pink_mist janl: heh, that's ancient
11:53 janl installed feb 22 2015
11:53 janl I'm quite comfortable using more time on my apps than updating frameworks ;-)
11:54 pink_mist err, that's a bit surprising considering 5.82 was released on feb 23 2015 :P (though maybe that's just a timezone issue)
11:55 janl I'm in CET
11:55 janl the previous maintainer for this app was a bit of a mojo-update-junkie.
11:56 pink_mist well, the online documentation won't be correct for your old version
11:56 pink_mist so if you want to read docs online, I would suggest updating =)
11:56 janl the enclosed perldoc was in agreement, but it did not mention 0 timeout.
11:57 pink_mist might have been a bug that was fixed
11:58 janl indeed
12:32 sri hahahaha
12:34 sri generally, update first, then ask here
13:00 orev joined #mojo
13:03 ramortegui joined #mojo
13:10 Janos joined #mojo
13:13 ptolemarch joined #mojo
13:13 zivester joined #mojo
13:25 marty joined #mojo
13:36 karjala How do you tell Minion that you only want 20 retries for each job? And that it should stop retrying after the 20th?
13:36 karjala I found the "backoff" attribute, but that's a function taking numbers up to infinity
13:37 karjala ah, i found it, it's a parameter in enqueue function
13:42 karjala sri: I think it would be good if you stated here whether high or low number for priority means higher priority: https://metacpan.org/pod/Minion#priority
13:42 karjala or maybe not
13:42 marty joined #mojo
13:43 gizmomathboy joined #mojo
13:44 sri karjala: how would you say that?
13:45 karjala Dunno, my english isn't that good.
13:45 sri ...
13:45 sri i had my editor open to update it
13:46 karjala jobs with a higher number will get executed firste
13:46 karjala first
13:46 karjala something like that
13:48 karjala sorry
13:48 cpan_mojo Mojolicious-Plugin-UniqueTagHelpers-0.05 by RSHADOW https://metacpan.org/release/RSHADOW/Mojolicious-Plugin-UniqueTagHelpers-0.05
13:49 nic that reads fine.  I'm guessing something as simple as ", where higher numbers equate to higher priority" works, if we agree that "higher priority" is widely understood
13:53 karjala sri: what nic said ^^
13:57 nicomen nic: like in unix?
13:58 janl no, in unix lower number is higher pri
13:58 asarch joined #mojo
14:15 karjala I think $ua->max_redirects(5) is a bit buggy. Let me show with a pastebin.
14:19 karjala http://pastebin.com/cE9Qt04X
14:19 PryMar56 joined #mojo
14:19 karjala This fails on my machine - the to_string shows 404 not found, and the next line that prints the code, prints undef
14:20 karjala on the browser, however, a normal page appears
14:20 karjala with ads
14:20 janl the ads are surely a bug
14:20 karjala does this script work dfferently on your machines?
14:23 janl this looks like 2 redirects
14:23 jberger I get one redirect and it works fine
14:24 jberger two one-liners for you: perl -Mojo -E 'say app->ua->max_redirects(1)->get("http://www.sweden.com")->res->code'
14:24 jberger and
14:24 jberger mojo get -r -v http://www.sweden.com 2>&1 | less
14:25 jberger -r is 10 redirects, so I also show explicitly 1 redirect in the first
14:32 karjala ok thanks
14:33 karjala my network is not good then
14:34 kaare joined #mojo
14:38 janl NYTProf's flame graph is nice
14:57 blonewolfs joined #mojo
14:59 zivester joined #mojo
15:40 disputin joined #mojo
16:14 ptolemarch joined #mojo
16:15 jacoby joined #mojo
16:18 lluad joined #mojo
16:30 disputin joined #mojo
16:33 rshadow joined #mojo
17:25 jamesaxl joined #mojo
17:37 stefan Is there a way to access a stack of all the templates that were rendered?
17:38 dod joined #mojo
18:14 gizmomathboy joined #mojo
18:32 disputin joined #mojo
18:52 disputin joined #mojo
19:02 Lee joined #mojo
19:08 dod joined #mojo
19:12 gizmomathboy joined #mojo
19:37 nelgin joined #mojo
19:38 asarch joined #mojo
19:39 nelgin Hi All. Grinnz has been helping me out on #perl but I think he's awol. I've got half what I need but still stuck with XML parsing. http://fpaste.scsys.co.uk/534452
19:39 nelgin Would appreciate some assitance
19:40 preaction what have you tried so far?
19:41 nelgin Yup, let me paste the code section.
19:42 nelgin http://fpaste.scsys.co.uk/534453
19:42 nelgin See if that makes any sense to you.
19:44 nelgin The xml in the first pastebin is just a scalar in the program
19:44 preaction what do you mean by $environment_names is "null in the debugger"?
19:45 nelgin SOrry, I meant undef
19:45 nelgin DB<1> x$environment_names
19:45 nelgin 0  undef
19:45 preaction that is also impossible, so i'm not sure what you mean
19:46 preaction it's not impossible before it's set. so i assume you're breaking on the line that's setting it (which is before it's set)
19:46 preaction did you try printing it out?
19:46 nelgin I'm breaking after the line that prints out the line
19:47 Grinnz that's before anything gets assigned to $environment_names
19:47 preaction there is no line after its set but before it goes out of scope for the next iteration of the loop
19:47 nelgin Ohh ok I see. Interesting
19:48 nelgin Yeah, I stuck a dumper line in there and I see it now. My bad.
19:48 Grinnz ftr, ->find (and thus ->map) will always return an arrayref, it might be empty but it'll still be an arrayref
19:48 Grinnz technically a Mojo::Collection blessed arrayref
19:49 nelgin Right. Yeah I didn't see the line number decrement when I did the print. OK, makes sense now.
19:50 nelgin but I need topull the href too.
19:50 nelgin from Environment
19:50 preaction so use the same code that gets the name and also get the href
19:51 Grinnz href and name can be accessed the same way, how exactly you call it depends on what you want the resulting structure to look like, or if you want to just loop through them individually (like with the Location tags)
19:55 nelgin Ace! Got it!
19:58 nelgin Well, not the href bit yet
19:58 nelgin I need to print the href and environment name on the same line
20:00 Grinnz make it an explicit loop to make it easier to follow: foreach my $environment (@{$location->find('Environments > Environment')}) { print "Environment Name: $environment->{name} href: $environment->{href}\n"; } # or however you want to format that
20:01 FatalNIX joined #mojo
20:01 FatalNIX wow
20:02 FatalNIX How is angular? works well with mojo? or is there much better stuff out there
20:03 Grinnz a more mojo-y way might be: $location->find('Environments > Environment')->each(sub { print "Environment Name: $_->{name} href: $_->{href}\n" });
20:03 Grinnz but that's a really long line and less readable for some
20:03 jberger FatalNIX: batman and I are using Vue.js lately, preaction will end up using it because I chose it too
20:04 Grinnz does preaction know about this yet? :P
20:04 FatalNIX I haven't used aly of those html frameworks
20:04 FatalNIX so I'm not sure what tothink of them
20:04 nelgin OK, let me try that then.
20:04 jberger Grinnz: yes :-P
20:05 FatalNIX I'm thinking about making a ticket system with mojo
20:05 FatalNIX so I figured something like angular would be neat to try with it
20:05 FatalNIX There are so many ticket systems and all of them always lack something really important for me so I said fuck it I'll just write one lol
20:06 batman FatalNIX: almost everyone i know that have used angular are looking for something else.
20:06 FatalNIX I see
20:07 batman but at the same time... it has a big user base and you don't need a "bleeding" (IE>=9) browser to use it.
20:07 FatalNIX I've heard nice things about polymer, but afaik polymer isn't something you integrate with mojolicious or some other framework, apparently polymer is an entire framework
20:07 nicomen what do you actually need, and how is a giant javascript framework going to solve that for you?
20:07 FatalNIX all stand-alone
20:07 Grinnz it's my understanding that anyone using any javascript framework tends to be looking for something else :P
20:07 nicomen answering those questions help finding the appropriate tool IMHO
20:08 nelgin Looks like that may do the trick.
20:09 FatalNIX nicomen: not quite sure, I've always done everything by hand, Somebody told me to check angularjs out to help with organizing my html objects, etc
20:09 FatalNIX and since I never used anything like it, I'm just not exactly sure what the hype is all about
20:12 nicomen I'm not sure what organizing html objects means
20:12 jberger the basic idea is that you have some data structure in your javascript and your frontend framework knows how to display it
20:13 nicomen like css?
20:13 nicomen ;-)
20:13 jberger and the nice thing about that is that in order to update the display all you have to do is manipulate the data structure
20:13 jberger which plays especially well with websocket-streamed updates
20:13 jberger or even api calls
20:16 FatalNIX nicomen: nah I use sass for my css stuff and that's been working well
20:17 nicomen I wonder if an <a> tag with target="{css-selector}" (and the borwser replacing the contents of that element with the content of the href) would've solved 95% of what one uses the frameworks for ;)
20:17 FatalNIX it'd be really cool if I could just have a bunch of tiny html templates that I can just use some dynamically creatable structure to be read from and just draw what's needed where.
20:17 FatalNIX like json or something
20:18 FatalNIX oh yeah jberger did some awesome websocket stuff with galileo
20:18 jberger nicomen: no, think more structural than that
20:19 FatalNIX jberger: yeah that pretty much seems what I wanted
20:19 jberger for example, here is my chat.pl example (Mojo::Pg flavored) but updated to use Vue: https://gist.github.com/jberger/8d09d4fa19aa54cff2d999c614380da3
20:19 FatalNIX if it's a data structure then you'd even be able to use say websockets to let the server just update the data structure at runtime
20:19 FatalNIX and js would just do the rest
20:19 jberger FatalNIX: exactly
20:20 FatalNIX I haven't found any web browsers that suck at websockets for a while so
20:20 jberger no, I assume they basically work now
20:20 jberger though I have only internal users so I get to say "upgrade that old crappy browser if you want it to work" :-P
20:20 FatalNIX such a feature would be very useful for a realtime ticket  / workorder system
20:21 FatalNIX I'm assuming customers will mostly be using just the email side of it
20:21 FatalNIX for my needs
20:21 FatalNIX maybe a page to easily submit them that wouldn't need anything special
20:28 nelgin Grinnz, thanks for your help. I may pester you later for more stuff :)
20:40 bpmedley Are, or were, y'all talking about MVVM?
20:40 jberger yeah
20:40 bpmedley And the Vue stuff you like works well with that?
20:41 jberger yep
20:42 batman vue <3
20:42 batman jberger ^^ do you see that heart?
20:43 bpmedley That's cool.  Do you think there will ever be a standard for widget/data interactions for disperse projects?  So, that picking and choosing presentation layer frameworks can be possible?  Does that make sense?
20:43 jberger this is where I have to admit that I don't have my new convos client up :-P
20:43 jberger old habits die hard :P
20:44 jberger actually I need to issue a new ssl cert for it
20:44 jberger I can't poke both out through my nginx until I have one for each (or one that covers both)
20:44 batman jberger: the heart is so beautiful. you should upgrade. convos is so easy to install :)
20:44 jberger no, its running
20:45 jberger it just isn't exposed to the outside world, I have to go into my nginx config and flip it over
20:45 batman bpmedley: i don't think so.
20:45 jberger perhaps that's a job for tonight while I sip aquavit and watch this farce of a debate
20:45 mpapec batman do you see doughnut in the topic?
20:45 batman mpapec: yeah
20:45 jberger bpmedley: the closest that will happen is web components if that ever happens
20:46 batman jberger: why wouldn't that happen?
20:46 jberger it might
20:46 mpapec I had it there before upgrade :/
20:46 jberger not all proposals happen
20:46 bpmedley Hrrm.  Is it the barrier for a standard communication, or technical?
20:47 * batman need some rest
20:47 jberger bpmedley: perhaps a better answer to your question (now that I read it again) is actually the observer api
20:47 jberger using that you can basically build interfaces between presentation frameworks
20:47 jberger it might be ugly but you could do it
20:48 * mpapec looking at http://www.stefankrause.net/wp/?p=316
20:48 mpapec new vue looks much faster
20:49 bpmedley However, isn't the observer api at a different level/layer?  I'm referring to something that would sit above the observer api, I believe..
20:58 mbizon joined #mojo
20:59 mbizon hello
20:59 mbizon when using MOJO_REVERSE_PROXY
20:59 mbizon what should I expect to have in tx->remote_address ?
21:00 mbizon the last proxy address, or the original client address
21:00 mbizon since they can be chained
21:00 mbizon return ($self->req->headers->header('X-Forwarded-For') // '') =~ /([^,\s]+)$/ ? $1 : $self->original_remote_address;
21:00 mbizon the code returns the rightmost ip address
21:00 mbizon which is the last proxy traversed
21:01 mbizon is that on purpose ?
21:02 nicomen IIRC: you need to traverse the list in reverse, and pick out the first non-trusted address
21:02 mbizon that is correct
21:02 nicomen I know it's hard to get it right, I've done it wrong before, but it's years ago now
21:02 mbizon but mojo has no advanced config to list the trusted peers
21:03 mbizon so it is not clear what remote_addr represent
21:04 nicomen true, so you can 1) let your proxy fix it up, or 2) use https://metacpan.org/pod/Mojolicious::Plugin::ClientIP
21:04 jberger mbizon: when reverse proxy mode is set most methods should try to make it seem as if there were no proxy at all
21:05 mbizon jberger: yes, and it works just fine, but I need the ip address for login & permission purpose
21:06 mbizon nicomen: that one seems to do it right thanks
21:06 jberger right, I'm just responding to "so it is not clear what remote_addr represent"
21:06 mbizon nicomen: I just tried another plugin before which was broken, did not handle multiple proxies
21:06 jberger it is clear from the perspective of the proxy should be transparent to the app
21:06 jberger getting what you NEED is a different story
21:07 mbizon sorry I don't follow
21:07 mbizon there is a "reverse_proxy" mode that is told to "handle X-Forwarded-For"
21:07 nicomen jberger: the XFF parsing of Mojolicious is a bit simplistic, it requires for instance to only have one proxy in front
21:07 mbizon but "handle" is unclear
21:08 jberger hmmm I hadn't considered more than one proxy
21:08 nicomen but overriding remote_address is of course "easier" for all other code that doesn't know about what plugin you are using
21:09 mbizon nicomen: Mojolicious::Plugin::RemoteAddr is the one broken
21:09 mbizon too many stuff on CPAN, should check source code :)
21:11 nicomen jberger: https://irclog.perlgeek.de/mojo/2014-08-27#i_9253698
21:13 nicomen I guess we can blame marcus :-P
21:16 jberger blaming marcus is nice
21:16 jberger especially since he's back in a mojo shop
21:16 nicomen I will mention it tomorrow at work
21:16 nicomen actually batman asked me why I reached for ::ClientIP today, and I had forgotten the real reason
21:16 jberger oh right, your mojo shop
21:16 nicomen (luckily I had plenty of other excuses)
21:17 mbizon that whole irc log should be part of the documentation
21:19 nicomen I don't like the problem with turning on reverse_proxy support but not being behind a proxy in particular
21:20 mbizon you mean it's easy to shoot yourself in the foot ?
21:20 nicomen a bit
21:20 nicomen I am not sure how people use Mojo apps out there
21:21 nicomen with a totally transparent proxy or straight to the world, a user can easily circumvent IP-blocks (which probably is evil anyway) by forging an XFF header
21:22 mbizon I think you should not be able to enable reverse proxy without giving a list of trusted sources
21:22 mbizon in the ngx_http_realip_module nginx module it goes together
21:22 mbizon you cannot miss it
21:28 * nicomen wonders if it supports X-Forwarded-Proto
21:29 mbizon no
21:29 mbizon for stuff like ->is_secure ?
21:31 nicomen when you for some reason need an absolute URL, or when you need to know if images and other stuff needs to be ssl
21:31 nicomen luckily everyone supports "//host/path" urls now
21:32 mbizon did not know that one
21:32 mbizon that means "same scheme" ?
21:32 nicomen yup
21:32 mbizon is that in a RFC ?
21:32 mbizon or just a browser bug that was copied by the others ?
21:32 nicomen - name: restart munin-node service: name=munin-node state=restarted
21:33 nicomen oops
21:33 nicomen http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just
21:33 disputin joined #mojo
21:33 Grinnz the tricky part is using wss: or ws: based on https: or http:
21:34 jberger protocol relative
21:34 Lee_ joined #mojo
21:41 sri tricky?
21:43 sri btw. if anyone plans to propose any big mojolicious changes or report big bugs, do it in the next few days
21:44 * sri will be spending the next 6 weeks at SUSE hq in nuremberg, and prolly won't be available much here
21:51 disputin joined #mojo
22:22 jberger does mojo automagically convert ?param[]=foo&param[]=bar into param?
22:22 jberger like $c->every_param('param')
22:22 jberger it seems like its doing that but I don't see where it happens
22:24 jberger hmmm, no
22:26 Grinnz it doesn't
22:27 Grinnz PHP does
22:30 jberger and yet something seems to be doing that
22:30 * Grinnz has a function which just merges ->every_param($foo) and ->every_param("$foo[]")
22:31 Grinnz javascript insists on adding [] to all its array params
22:31 jberger right
22:31 jberger that is the problem I have
22:31 jberger and yet unexpectedly it actually seemed to work
22:32 jberger maybe swagger is fixing it up?
22:33 jberger ha
22:33 jberger no
22:34 jberger I built my endpoint as a search
22:34 jberger with multiple ids it limits the results to those ids
22:34 jberger with NO ideas it doesn't limit by id
22:34 Grinnz lol
22:34 jberger and with id[] it sees ... no ids
22:34 jberger sigh
22:35 Grinnz so, bug in the test :P
22:35 jberger basically
22:35 jberger where the test at the moment is me looking at the output and being confused why I saw anything
22:35 jberger it wasn't until I saw an id that I didn't actually request that it made sense
22:36 jberger I don't want swagger to handle that actually
22:36 jberger which mean, I gotta build my query string in javascript by hand, yay!
22:40 Lee joined #mojo
22:41 jberger oh, $.param({...}, true) works
22:41 jberger that's better than nothin
22:52 nicomen Grinnz: sounds like a nice plugin to have though
22:53 Grinnz eh dunno how well it would work as a plugin
22:53 Grinnz i guess if you're ok calling something other than ->param
22:54 nicomen can't a plugin register a before dispatch?
22:54 Grinnz (i hadn't actually reimplemented my function as a helper but now that you mention it I should)
22:54 Grinnz i'd rather not have something actually munge the request parameters, this is just to retrieve them
22:55 Grinnz plus it's a bit wasteful...
22:56 nicomen hm
23:25 vytas joined #mojo
23:30 cpan_mojo Mojolicious-Plugin-SecureOnly-0.03 by SADAMS https://metacpan.org/release/SADAMS/Mojolicious-Plugin-SecureOnly-0.03
23:35 disputin joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary