annotate mod_pastebin/mod_pastebin.lua @ 438:7f0cdde1e42a

mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Sep 2011 12:47:33 +0100
parents 7a695ee3884b
children 82ccfba5ac2f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local st = require "util.stanza";
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local httpserver = require "net.httpserver";
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local uuid_new = require "util.uuid".generate;
12
316e8437f233 mod_pastebin: Allow configurable message length threshold
Matthew Wild <mwild1@gmail.com>
parents: 5
diff changeset
5 local os_time = os.time;
24
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
6 local t_insert, t_remove = table.insert, table.remove;
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
7 local add_task = require "util.timer".add_task;
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8
438
7f0cdde1e42a mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
Matthew Wild <mwild1@gmail.com>
parents: 190
diff changeset
9 local pastebin_private_messages = module:get_option_boolean("pastebin_private_messages", hosts[module.host].type ~= "component");
7f0cdde1e42a mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
Matthew Wild <mwild1@gmail.com>
parents: 190
diff changeset
10
190
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
11 local function drop_invalid_utf8(seq)
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
12 local start = seq:byte();
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
13 module:log("utf8: %d, %d", start, #seq);
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
14 if (start <= 223 and #seq < 2)
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
15 or (start >= 224 and start <= 239 and #seq < 3)
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
16 or (start >= 240 and start <= 244 and #seq < 4)
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
17 or (start > 244) then
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
18 return "";
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
19 end
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
20 return seq;
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
21 end
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
22
23
92b1e6592d36 mod_pastebin: Allow per-host pastebin_threshold
Matthew Wild <mwild1@gmail.com>
parents: 21
diff changeset
23 local length_threshold = config.get(module.host, "core", "pastebin_threshold") or 500;
167
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
24 local line_threshold = config.get(module.host, "core", "pastebin_line_threshold") or 4;
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25
21
4f18696f043a mod_pastebin: Small fix to read the pastebin URL from the config
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
26 local base_url = config.get(module.host, "core", "pastebin_url");
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27
24
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
28 -- Seconds a paste should live for in seconds (config is in hours), default 24 hours
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
29 local expire_after = math.floor((config.get(module.host, "core", "pastebin_expire_after") or 24) * 3600);
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
30
156
b51741b7e86d mod_pastebin: Optionally bin if message starts with a configurable trigger string
Florian Zeitz <florob@babelmonkeys.de>
parents: 76
diff changeset
31 local trigger_string = config.get(module.host, "core", "pastebin_trigger");
167
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
32 trigger_string = (trigger_string and trigger_string .. " ");
156
b51741b7e86d mod_pastebin: Optionally bin if message starts with a configurable trigger string
Florian Zeitz <florob@babelmonkeys.de>
parents: 76
diff changeset
33
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 local pastes = {};
76
1fc4e8dc66a6 mod_pastebin: Send Content-Type header to specify plain UTF-8 text
Matthew Wild <mwild1@gmail.com>
parents: 75
diff changeset
35 local default_headers = { ["Content-Type"] = "text/plain; charset=utf-8" };
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im";
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 local xmlns_xhtml = "http://www.w3.org/1999/xhtml";
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39
75
3c7189e26848 mod_pastebin: Rename pastebin_message() to pastebin_text() and make it global so it can be called by other plugins
Matthew Wild <mwild1@gmail.com>
parents: 71
diff changeset
40 function pastebin_text(text)
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 local uuid = uuid_new();
76
1fc4e8dc66a6 mod_pastebin: Send Content-Type header to specify plain UTF-8 text
Matthew Wild <mwild1@gmail.com>
parents: 75
diff changeset
42 pastes[uuid] = { body = text, time = os_time(), headers = default_headers };
24
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
43 pastes[#pastes+1] = uuid;
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
44 if not pastes[2] then -- No other pastes, give the timer a kick
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
45 add_task(expire_after, expire_pastes);
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
46 end
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 return base_url..uuid;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 function handle_request(method, body, request)
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 local pasteid = request.url.path:match("[^/]+$");
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 if not pasteid or not pastes[pasteid] then
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 return "Invalid paste id, perhaps it expired?";
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 --module:log("debug", "Received request, replying: %s", pastes[pasteid].text);
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57
76
1fc4e8dc66a6 mod_pastebin: Send Content-Type header to specify plain UTF-8 text
Matthew Wild <mwild1@gmail.com>
parents: 75
diff changeset
58 return pastes[pasteid];
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 function check_message(data)
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 local origin, stanza = data.origin, data.stanza;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 local body, bodyindex, htmlindex;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 for k,v in ipairs(stanza) do
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 if v.name == "body" then
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 body, bodyindex = v, k;
71
3c18c2d03bc2 mod_pastebin: Fix finding of XHTML content.
Paul Aurich <paul@darkrain42.org>
parents: 25
diff changeset
68 elseif v.name == "html" and v.attr.xmlns == xmlns_xhtmlim then
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 htmlindex = k;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 if not body then return; end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 body = body:get_text();
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75
25
ea59a8d98b03 mod_pastebin: Comment some debug logging on every message
Matthew Wild <mwild1@gmail.com>
parents: 24
diff changeset
76 --module:log("debug", "Body(%s) length: %d", type(body), #(body or ""));
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77
167
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
78 if body and (
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
79 (#body > length_threshold) or
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
80 (trigger_string and body:find(trigger_string, 1, true) == 1) or
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
81 (select(2, body:gsub("\n", "%0")) >= line_threshold)
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
82 ) then
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
83 if trigger_string then
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
84 body = body:gsub("^" .. trigger_string, "", 1);
0d37d18ea073 mod_pastebin: Fix trigger_string matching when no trigger is set, and add support for counting lines (pastebin_line_threshold, default: 4)
Matthew Wild <mwild1@gmail.com>
parents: 156
diff changeset
85 end
75
3c7189e26848 mod_pastebin: Rename pastebin_message() to pastebin_text() and make it global so it can be called by other plugins
Matthew Wild <mwild1@gmail.com>
parents: 71
diff changeset
86 local url = pastebin_text(body);
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 module:log("debug", "Pasted message as %s", url);
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 --module:log("debug", " stanza[bodyindex] = %q", tostring( stanza[bodyindex]));
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 stanza[bodyindex][1] = url;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml });
190
7a695ee3884b mod_pastebin: Better fix for stripping truncated UFT-8 sequences
Matthew Wild <mwild1@gmail.com>
parents: 189
diff changeset
91 html:tag("p"):text(body:sub(1,150):gsub("[\194-\244][\128-\191]*$", drop_invalid_utf8)):up();
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 html:tag("a", { href = url }):text("[...]"):up();
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 stanza[htmlindex or #stanza+1] = html;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 module:hook("message/bare", check_message);
438
7f0cdde1e42a mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
Matthew Wild <mwild1@gmail.com>
parents: 190
diff changeset
98 if pastebin_private_messages then
7f0cdde1e42a mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
Matthew Wild <mwild1@gmail.com>
parents: 190
diff changeset
99 module:hook("message/full", check_message);
7f0cdde1e42a mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
Matthew Wild <mwild1@gmail.com>
parents: 190
diff changeset
100 end
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101
24
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
102 function expire_pastes(time)
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
103 time = time or os_time(); -- COMPAT with 0.5
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
104 if pastes[1] then
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
105 pastes[pastes[1]] = nil;
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
106 t_remove(pastes, 1);
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
107 if pastes[1] then
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
108 return (expire_after - (time - pastes[pastes[1]].time)) + 1;
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
109 end
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
110 end
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
111 end
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
112
72bcc0475e2f mod_pastebin: Expire pastes after 'pastebin_expire_after' hours, 24 by default
Matthew Wild <mwild1@gmail.com>
parents: 23
diff changeset
113
5
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 local ports = config.get(module.host, "core", "pastebin_ports") or { 5280 };
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 for _, options in ipairs(ports) do
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 local port, base, ssl, interface = 5280, "pastebin", false, nil;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 if type(options) == "number" then
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 port = options;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 elseif type(options) == "table" then
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 port, base, ssl, interface = options.port or 5280, options.path or "pastebin", options.ssl or false, options.interface;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 elseif type(options) == "string" then
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 base = options;
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 end
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 base_url = base_url or ("http://"..module:get_host()..(port ~= 80 and (":"..port) or "").."/"..base.."/");
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 httpserver.new{ port = port, base = base, handler = handle_request, ssl = ssl }
9c1c6c5344dc mod_pastebin: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 end