This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Mojolicious::Plugin::Coro; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
use Coro; | |
use Mojo::IOLoop; | |
# Wrap application in coroutine and reschedule main coroutine in event loop | |
sub register { | |
my ($self, $app) = @_; | |
my $subscribers = $app->plugins->subscribers('around_dispatch'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generate 2 certficate: | |
openssl req -nodes -new -x509 -keyout client.key -out client.cert | |
openssl req -nodes -new -x509 -keyout server.key -out server.cert | |
run server: | |
morbo server.pl -l 'https://*:3000?cert=./server.cert&key=./server.key&ca=client.cert' | |
run client: | |
openssl s_client -connect 127.0.0.1:3000 -cert client.cert -key client.key | |
GET / HTTP/1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to run simple execute: morbo 1.pl | |
# go to link htpp://127.0.0.1:3000/ | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
use Mojo::IOLoop::ReadWriteFork; | |
get '/' => 'index'; | |
websocket '/find' => sub { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Mojo::Base -strict; | |
use Mojo::IOLoop; | |
use Mojo::UserAgent; | |
my %connections; | |
Mojo::IOLoop->server({port => 3128} => sub { | |
my ($loop, $stream_client, $client_id) = @_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# To run need listen two ports: 80, 443 | |
# sudo morbo 12.pl -l https://*:443?cert%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.crt%26key%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.key%26verify%3D0x00 -l http://*:80 | |
# go to url in browser http://your_ip/qwe/asd | |
use Mojo::Base -strict; | |
use Mojolicious::Lite; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Mojo::Base -strict; | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
use Mojo::IOLoop::ReadWriteFork; | |
plugin 'Mojolicious::Plugin::ForkCall'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use v5.10; | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
use Mojo::IOLoop::ReadWriteFork; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
package Mojo::IOLoop::Net::DNS; | |
use Mojo::Base -base; | |
use Net::DNS; | |
use Mojo::IOLoop; | |
use Scalar::Util 'weaken'; | |
sub query { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/use/bin/perl | |
use Mojo::Base -strict; | |
use Socket qw/:DEFAULT SOCK_NONBLOCK getaddrinfo/; | |
use EV; | |
my $host = 'localhost'; | |
my $port = '27017'; | |
my ($tcp_name, $tcp_alias, $tcp_proto) = getprotobyname('tcp'); | |
my ($err, @hosts) = getaddrinfo($host, $port, {protocol => $tcp_proto}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/use/bin/perl | |
use Mojo::Base -strict; | |
use Socket qw/:DEFAULT SOCK_NONBLOCK getaddrinfo unpack_sockaddr_in inet_pton getnameinfo inet_ntop/; | |
use EV; | |
use Data::Dumper; | |
my $host = 'localhost'; | |
my $port = '3000'; | |
my ($tcp_name, $tcp_alias, $tcp_proto) = getprotobyname('tcp'); |