App-phoebe
view release on metacpan or search on metacpan
sudo adduser --disabled-login --disabled-password phoebe
sudo su phoebe --shell=/bin/bash
cd
Now you're in your home directory, `/home/phoebe`. We're going to install
things right here.
cpan App::phoebe
Start Phoebe. It's going to prompt you for a hostname and create certificates
for you. If in doubt, answer `localhost`. The certificate and a private key are
stored in the `cert.pem` and `key.pem` files, using elliptic curves, valid for
five years, without password protection.
perl5/bin/phoebe
This starts the server in the foreground. If it aborts, see the
["Troubleshooting"](#troubleshooting) section below. If it runs, open a second terminal and test
it:
The _Listen URL_ is where you need to _stream_: as people say things in the
room, these messages get streamed in one endless Gemini document. You might have
to set an appropriate timeout period for your connection for this to work. 1h,
perhaps?
The URL will look something like this:
`gemini://localhost/do/chat/listen` or
`gemini://localhost/space/do/chat/listen`
The _Say URL_ is where you post things you want to say: point your client at
the URL, it prompts your for something to say, and once you do, it redirects you
to the same URL again, so you can keep saying things.
The URL will look something like this: `gemini://localhost/do/chat/say` or
`gemini://localhost/space/do/chat/say`
Your chat nickname is the client certificate's common name. One way to create a
client certificate that's valid for five years with an appropriate common name:
openssl req -new -x509 -newkey ec \
-pkeyopt ec_paramgen_curve:prime256v1 \
lib/App/Phoebe/Chat.pm view on Meta::CPAN
The I<Listen URL> is where you need to I<stream>: as people say things in the
room, these messages get streamed in one endless Gemini document. You might have
to set an appropriate timeout period for your connection for this to work. 1h,
perhaps?
The URL will look something like this:
C<gemini://localhost/do/chat/listen> or
C<gemini://localhost/space/do/chat/listen>
The I<Say URL> is where you post things you want to say: point your client at
the URL, it prompts your for something to say, and once you do, it redirects you
to the same URL again, so you can keep saying things.
The URL will look something like this: C<gemini://localhost/do/chat/say> or
C<gemini://localhost/space/do/chat/say>
Your chat nickname is the client certificate's common name. One way to create a
client certificate that's valid for five years with an appropriate common name:
openssl req -new -x509 -newkey ec \
-pkeyopt ec_paramgen_curve:prime256v1 \
script/gemini-chat view on Meta::CPAN
my $host = domain_to_ascii(decode_utf8 $iri->host);
my $port = $iri->port || 1965;
my $unsafe = "^A-Za-z0-9\-\._~"; # the default
my $path = uri_escape_utf8($iri->path, $unsafe . "/"); # path separator are safe
$uri = $iri->scheme . '://' . $host . ':' . $port;
$uri .= $path if $path;
# start read loop for saying stuff
my $term = Term::ReadLine->new($uri);
my $prompt = "> ";
my $OUT = $term->OUT || \*STDOUT;
while (defined ($_ = $term->readline($prompt))) {
exit if $_ eq "quit";
# create client
my $text = uri_escape_utf8($_);
Mojo::IOLoop->client({
address => $host,
port => $port,
tls => 1,
tls_cert => $cert,
tls_key => $key,
tls_options => { SSL_verify_mode => 0x00 }} => sub {
script/ijirait view on Meta::CPAN
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
}
sub play {
say "Use 'quit' to leave the game. Use '\\' to send a newline.";
my @queue = qw(look);
# start read loop for saying stuff
my $term = Term::ReadLine->new("Ijirait");
my $prompt = "> ";
my $OUT = $term->OUT || \*STDOUT;
while (defined ($_ = shift(@queue) || $term->readline($prompt))) {
exit if $_ eq "quit";
# Handle <
my $command = decode(locale => $_);
if ($command =~ /^(.*?)\s*<\s*([^|<>]+?)\s*$/s) {
if (-f $2) {
$command = $1 . " " . decode_utf8(read_text($2));
} else {
say "Cannot read $2";
next;
}
script/phoebe view on Meta::CPAN
sudo adduser --disabled-login --disabled-password phoebe
sudo su phoebe --shell=/bin/bash
cd
Now you're in your home directory, F</home/phoebe>. We're going to install
things right here.
cpan App::phoebe
Start Phoebe. It's going to prompt you for a hostname and create certificates
for you. If in doubt, answer C<localhost>. The certificate and a private key are
stored in the F<cert.pem> and F<key.pem> files, using elliptic curves, valid for
five years, without password protection.
perl5/bin/phoebe
This starts the server in the foreground. If it aborts, see the
L</Troubleshooting> section below. If it runs, open a second terminal and test
it:
script/phoebe view on Meta::CPAN
sub generate_certificates {
say "The default certificate (and key) files are missing.";
say "Do you want to create them right now?";
say "The certificate uses eliptic curves and is valid for five years.";
say "If so, please provide your hostname (e.g. localhost).";
say "If not, just press Enter.";
local $SIG{'ALRM'} = sub {
die "Timed out!\n";
};
alarm(30); # timeout for the following prompt
my $hostname = <STDIN>;
alarm(0); # done, no more alarm
chomp $hostname;
die "The hostname may not contain any whitespace\n" if $hostname =~ /\s/;
my $cmd = qq(openssl req -new -x509 -newkey ec -subj "/CN=$hostname" )
. qq(-pkeyopt ec_paramgen_curve:prime256v1 -days 1825 -nodes -out cert.pem -keyout key.pem);
if ($hostname) {
say $cmd;
system($cmd) == 0
or die "openssl failed: $?";
t/Wikipedia.t view on Meta::CPAN
# make sure starting phoebe starts knows localhost is the proxy
our @config = (<<'EOT');
package App::Phoebe::Wikipedia;
our $host = "localhost";
EOT
require './t/test.pl';
like(query_gemini("$base/"),
qr/^10.*language/, "Top level is a prompt");
like(query_gemini("$base/?en"),
qr/^30.*\/en\r\n/, "Redirect for the language");
like(query_gemini("$base/en"),
qr/^10.*term/, "Search term prompt");
like(query_gemini("$base/en?Project%20Gemini"),
qr/^30.*\/search\/en\/Project%20Gemini\r\n/, "Redirect for the term");
SKIP: {
skip "Making requests to Wikipedia requires \$ENV{TEST_AUTHOR} > 2", 2
unless $ENV{TEST_AUTHOR} and $ENV{TEST_AUTHOR} > 2;
like(query_gemini("$base/search/en/Project%20Gemini"),
qr/^20/, "List of terms");
like(query_gemini("$base/text/en/Project%20Gemini"),
( run in 0.673 second using v1.01-cache-2.11-cpan-0b5f733616e )