codebot 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +32 -0
  3. data/.github/ISSUE_TEMPLATE/formatter_issue.md +20 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  5. data/.gitignore +10 -0
  6. data/.rspec +1 -0
  7. data/.rubocop.yml +11 -0
  8. data/.travis.yml +26 -0
  9. data/CODE_OF_CONDUCT.md +46 -0
  10. data/CONTRIBUTING.md +15 -0
  11. data/Gemfile +4 -0
  12. data/Gemfile.lock +75 -0
  13. data/LICENSE +21 -0
  14. data/README.md +230 -0
  15. data/Rakefile +29 -0
  16. data/bin/console +8 -0
  17. data/codebot.gemspec +49 -0
  18. data/exe/codebot +7 -0
  19. data/lib/codebot.rb +8 -0
  20. data/lib/codebot/channel.rb +134 -0
  21. data/lib/codebot/command_error.rb +17 -0
  22. data/lib/codebot/config.rb +125 -0
  23. data/lib/codebot/configuration_error.rb +17 -0
  24. data/lib/codebot/core.rb +76 -0
  25. data/lib/codebot/cryptography.rb +38 -0
  26. data/lib/codebot/event.rb +62 -0
  27. data/lib/codebot/ext/cinch/ssl_extensions.rb +37 -0
  28. data/lib/codebot/formatter.rb +242 -0
  29. data/lib/codebot/formatters.rb +109 -0
  30. data/lib/codebot/formatters/.rubocop.yml +2 -0
  31. data/lib/codebot/formatters/commit_comment.rb +43 -0
  32. data/lib/codebot/formatters/fork.rb +40 -0
  33. data/lib/codebot/formatters/gitlab_issue_hook.rb +56 -0
  34. data/lib/codebot/formatters/gitlab_job_hook.rb +77 -0
  35. data/lib/codebot/formatters/gitlab_merge_request_hook.rb +57 -0
  36. data/lib/codebot/formatters/gitlab_note_hook.rb +119 -0
  37. data/lib/codebot/formatters/gitlab_pipeline_hook.rb +51 -0
  38. data/lib/codebot/formatters/gitlab_push_hook.rb +83 -0
  39. data/lib/codebot/formatters/gitlab_wiki_page_hook.rb +56 -0
  40. data/lib/codebot/formatters/gollum.rb +67 -0
  41. data/lib/codebot/formatters/issue_comment.rb +41 -0
  42. data/lib/codebot/formatters/issues.rb +41 -0
  43. data/lib/codebot/formatters/ping.rb +79 -0
  44. data/lib/codebot/formatters/public.rb +30 -0
  45. data/lib/codebot/formatters/pull_request.rb +71 -0
  46. data/lib/codebot/formatters/pull_request_review_comment.rb +49 -0
  47. data/lib/codebot/formatters/push.rb +172 -0
  48. data/lib/codebot/formatters/watch.rb +38 -0
  49. data/lib/codebot/integration.rb +195 -0
  50. data/lib/codebot/integration_manager.rb +225 -0
  51. data/lib/codebot/ipc_client.rb +83 -0
  52. data/lib/codebot/ipc_server.rb +79 -0
  53. data/lib/codebot/irc_client.rb +102 -0
  54. data/lib/codebot/irc_connection.rb +156 -0
  55. data/lib/codebot/message.rb +37 -0
  56. data/lib/codebot/metadata.rb +15 -0
  57. data/lib/codebot/network.rb +240 -0
  58. data/lib/codebot/network_manager.rb +181 -0
  59. data/lib/codebot/options.rb +49 -0
  60. data/lib/codebot/options/base.rb +55 -0
  61. data/lib/codebot/options/core.rb +126 -0
  62. data/lib/codebot/options/integration.rb +101 -0
  63. data/lib/codebot/options/network.rb +109 -0
  64. data/lib/codebot/payload.rb +32 -0
  65. data/lib/codebot/request.rb +51 -0
  66. data/lib/codebot/sanitizers.rb +130 -0
  67. data/lib/codebot/serializable.rb +101 -0
  68. data/lib/codebot/shortener.rb +43 -0
  69. data/lib/codebot/thread_controller.rb +70 -0
  70. data/lib/codebot/user_error.rb +13 -0
  71. data/lib/codebot/validation_error.rb +17 -0
  72. data/lib/codebot/web_listener.rb +107 -0
  73. data/lib/codebot/web_server.rb +58 -0
  74. data/webhook.png +0 -0
  75. metadata +249 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: afdf8aa17931f5664a340884f1aa57e54b504d145473dd80ead27a475562ac34
4
+ data.tar.gz: 6fa0fc77a5a4373e608dc29fbc68b415bc9260d462c54aad810d8335f1e0a5ac
5
+ SHA512:
6
+ metadata.gz: 8db55c49dd1a113c594707f5fc1f84445b3867a7a80a2d34ae86ca1f93b278be302f357b5c93ed5bca1d77bcbea6c05d211b0367315c19858dab3fd8798f53ca
7
+ data.tar.gz: 294e854c4c7c94723080374466dd1322728faf7ae2475f61995e279dfc31b16688571336e81137c395e61ba4964d1e829b497cc4dcae14edbad33e2798a992c1
@@ -0,0 +1,32 @@
1
+ ## Expected Behavior
2
+
3
+ <!-- If you're reporting a bug, explain what you expected to happen -->
4
+ <!-- If you're suggesting an improvement, please elaborate on your idea -->
5
+
6
+ ## Actual Behavior
7
+
8
+ <!-- Describe how the current behavior differs from what you expected -->
9
+
10
+ ## Proposed Solution
11
+
12
+ <!-- Explain how the change could be implemented, or delete this section -->
13
+
14
+ ## Steps to Reproduce
15
+
16
+ <!-- Unless you're reporting a bug, please delete this section -->
17
+
18
+ 1. ?
19
+ 2. ?
20
+ 3. ?
21
+
22
+ ## Ruby Version
23
+
24
+ <!-- Unless you're reporting a bug, please delete this section -->
25
+
26
+ ```
27
+ Please replace this line with the output of `ruby --version`
28
+ ```
29
+
30
+ ## Additional Information
31
+
32
+ <!-- If you have any other comments, please add them here -->
@@ -0,0 +1,20 @@
1
+ <!--
2
+ If you received a notification that started with "An error occurred while
3
+ formatting this message", please report the issue here.
4
+
5
+ If you're not the owner of the bot, please ask the owner to open an issue
6
+ instead.
7
+ -->
8
+
9
+ ## Error Report
10
+
11
+ <!-- If you used the `codebot core interactive` command, an error report should
12
+ have been printed to `stderr` (the standard error stream). If you don't
13
+ know how to find it, don't worry — we're here to help! -->
14
+
15
+ <!-- Replace this line with the error report if you have one. -->
16
+
17
+ ## Additional Information
18
+
19
+ <!-- If you know which event led to this issue or have any other information
20
+ that might be useful, please include it here. -->
@@ -0,0 +1,13 @@
1
+ ## Description
2
+
3
+ <!-- Please describe your changes in detail -->
4
+ <!-- If this pull request fixes an open issue, please link to it -->
5
+
6
+ ## Checklist
7
+
8
+ <!-- Please put an "x" in all boxes that apply -->
9
+ <!-- If you're not sure, don't hesitate to ask. We're here to help. -->
10
+
11
+ - [ ] I have read the **CONTRIBUTING.md** file
12
+ - [ ] I have updated any relevant documentation
13
+ - [ ] I have run `rubocop` and no offenses were detected
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/examples.txt
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ Style/FrozenStringLiteralComment:
5
+ EnforcedStyle: always
6
+
7
+ Layout/EndOfLine:
8
+ EnforcedStyle: lf
9
+
10
+ Layout/IndentHeredoc:
11
+ EnforcedStyle: squiggly
@@ -0,0 +1,26 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ dist: trusty
5
+ rvm:
6
+ - 2.3.6
7
+ - 2.4.3
8
+ - 2.5.0
9
+ - ruby-head
10
+ - jruby-9.1.16.0
11
+ - jruby-head
12
+ env:
13
+ global:
14
+ - JRUBY_OPTS='--debug -J-Xmx1000M'
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: ruby-head
18
+ - rvm: jruby-head
19
+ fast_finish: true
20
+ before_install:
21
+ - gem update --system
22
+ - gem update --remote bundler
23
+ install:
24
+ - bundle install --retry=3
25
+ script:
26
+ - bundle exec rake check
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at codebot@olabini.se. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,15 @@
1
+ # Contributing
2
+
3
+ Thank you for your interest in contributing to Codebot.
4
+ Here is some information to help you get started:
5
+
6
+ * Please take a look at the [Code of Conduct](CODE_OF_CONDUCT.md) before
7
+ contributing to Codebot.
8
+ * Issues and pull requests are always welcome, even if you just want to give
9
+ feedback or ask a question.
10
+ * If you're planning on working on a major feature, we recommend to first open
11
+ an issue to discuss your idea.
12
+ * Before creating a pull request, please run `rubocop` and make sure it does
13
+ not report any offenses.
14
+ * If you need help or have a question, don't hesitate to open an issue and ask.
15
+ We're here to help!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ codebot (1.2.0)
5
+ cinch (~> 2.3)
6
+ cinch-identify (~> 1.7)
7
+ irb (~> 1.0)
8
+ sinatra (~> 2.0)
9
+ thor (~> 0.20.0)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ ast (2.4.0)
15
+ cinch (2.3.4)
16
+ cinch-identify (1.7.0)
17
+ cinch (~> 2.0)
18
+ diff-lcs (1.3)
19
+ irb (1.0.0)
20
+ jaro_winkler (1.5.2)
21
+ mustermann (1.0.3)
22
+ parallel (1.14.0)
23
+ parser (2.6.0.0)
24
+ ast (~> 2.4.0)
25
+ powerpack (0.1.2)
26
+ psych (3.1.0)
27
+ rack (2.0.6)
28
+ rack-protection (2.0.5)
29
+ rack
30
+ rainbow (3.0.0)
31
+ rake (12.3.2)
32
+ rspec (3.8.0)
33
+ rspec-core (~> 3.8.0)
34
+ rspec-expectations (~> 3.8.0)
35
+ rspec-mocks (~> 3.8.0)
36
+ rspec-core (3.8.0)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-expectations (3.8.2)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.8.0)
41
+ rspec-mocks (3.8.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.8.0)
44
+ rspec-support (3.8.0)
45
+ rubocop (0.65.0)
46
+ jaro_winkler (~> 1.5.1)
47
+ parallel (~> 1.10)
48
+ parser (>= 2.5, != 2.5.1.1)
49
+ powerpack (~> 0.1)
50
+ psych (>= 3.1.0)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (~> 1.4.0)
54
+ ruby-progressbar (1.10.0)
55
+ sinatra (2.0.5)
56
+ mustermann (~> 1.0)
57
+ rack (~> 2.0)
58
+ rack-protection (= 2.0.5)
59
+ tilt (~> 2.0)
60
+ thor (0.20.3)
61
+ tilt (2.0.9)
62
+ unicode-display_width (1.4.1)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler (~> 2.0)
69
+ codebot!
70
+ rake (~> 12.3)
71
+ rspec (~> 3.8)
72
+ rubocop (~> 0.65.0)
73
+
74
+ BUNDLED WITH
75
+ 2.0.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+ Copyright © 2018-2019 Janik Rabe
3
+ Copyright © 2019 Ola Bini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,230 @@
1
+ # Codebot
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/codebot.svg)](https://rubygems.org/gems/codebot)
4
+ [![Gem Downloads](https://img.shields.io/gem/dt/codebot.svg)](https://rubygems.org/gems/codebot)
5
+
6
+ Codebot is an IRC bot that receives GitHub and GitLab webhooks and forwards them to
7
+ IRC channels. It is designed to send messages in a format similar to that
8
+ of the official GitHub IRC Service. Codebot is able to stay connected after
9
+ sending messages. This eliminates the delays and visual clutter caused by
10
+ reconnecting each time a new message has to be delivered.
11
+
12
+ In addition, Codebot is able to handle many events the official service does not
13
+ support. Messages for these events are designed to be as consistent as possible
14
+ with official messages. If these additional notifications are not desired, they
15
+ can be disabled through the webhook settings.
16
+
17
+ ## Features
18
+
19
+ * **Secure by default**. Codebot automatically generates strong random secrets
20
+ for each webhook to ensure the integrity of received data.
21
+ * **Highly configurable**. Codebot supports IRC over TLS, SASL authentication,
22
+ password-protected IRC servers, channel keys, address binding, and more.
23
+ * **Easy to set up**. Setting up Codebot takes three minutes — no need to edit
24
+ configuration files or memorize complicated commands.
25
+ * **Supports many events**. Codebot supports all events supported by GitHub's
26
+ official IRC integration, and a few more. Individual events can be enabled
27
+ or disabled through the webhook settings.
28
+ * **Unlimited networks, channels and integrations**. A single instance can
29
+ receive notifications for any number of webhooks and forward them to the
30
+ appropriate channels on as many IRC networks as you want.
31
+ * **On-the-fly reloading**. A running Codebot instance can automatically pick
32
+ up any new changes with no restart required. (*Changes to channel lists
33
+ currently still require a restart to take effect.*)
34
+ * **Powered by Rack and Sinatra**. Thanks to Rack, Codebot can work with almost
35
+ any web server, including the default `WEBrick` server for smaller instances.
36
+
37
+ ## Installation
38
+
39
+ You can install Codebot from [RubyGems][rubygem] by issuing the following
40
+ command:
41
+
42
+ ```
43
+ $ gem install codebot
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ Getting Codebot up and running only takes a few minutes.
49
+
50
+ ### Add a network
51
+
52
+ First, add the IRC networks you want to send notifications to. Remove `--secure`
53
+ if you need to connect without TLS.
54
+
55
+ ```
56
+ $ codebot network create freenode --host chat.freenode.net --nick bot --secure
57
+ Network was successfully created
58
+ Network: freenode
59
+ Server: chat.freenode.net:6697 (secure connection)
60
+ Nickname: bot
61
+ SASL authentication disabled
62
+ ```
63
+
64
+ Please see `codebot network help create` for a list of possible options.
65
+ Networks can be modified using `codebot network update` and deleted
66
+ using the `codebot network destroy` command.
67
+
68
+ ### Add an integration
69
+
70
+ Next, create an integration. Integrations are responsible for mapping a webhook
71
+ endpoint to a set of IRC channels. You can use the same endpoint for as many
72
+ repositories and organizations as you wish.
73
+
74
+ ```
75
+ $ codebot integration create my-project -c freenode/#chan1 freenode/#chan2
76
+ Integration was successfully created
77
+ Integration: my-project
78
+ Endpoint: cc5dc492-1b6a-4e13-9da9-a9cc740add1d
79
+ Secret: WIcSmr6bsHmv9EmaONMQ1dViu5ziKYN3gUhXoyZBh3M=
80
+ Channels:
81
+ - #chan1 on freenode
82
+ - #chan2 on freenode
83
+ ```
84
+
85
+ You can specify a custom endpoint using the `--endpoint` option and a custom
86
+ secret using the `--secret` option. If the secret is set to an empty string,
87
+ the integrity of payloads will not be verified. This is highly discouraged.
88
+
89
+ Please see `codebot integration help create` for a list of possible options.
90
+ Integrations can be modified using `codebot integration update` and deleted
91
+ using the `codebot integration destroy` command.
92
+
93
+ ### Configure your webhook
94
+
95
+ You can now [add a GitHub webhook][newhook] to any repositories and
96
+ organizations you'd like to receive notifications from.
97
+
98
+ ![Sample webhook configuration](webhook.png)
99
+
100
+ Unless [otherwise configured][gateway], **Payload URL** should be in the format
101
+ `http://server:4567/endpoint`, where `server` is the IP address or host name of
102
+ the server Codebot is running on, and `endpoint` the endpoint generated in the
103
+ previous step. Please see [Gateway Configuration][gateway] for information on
104
+ how to receive webhooks over HTTPS, and [Environment Variables][environ] if you
105
+ would like Codebot to listen on a different port.
106
+
107
+ Both possible **Content type** values are supported, but it is recommended to
108
+ use `application/json`.
109
+
110
+ **Secret** should be set to the secret created in the previous step. This value
111
+ is used for verifying the integrity of received payloads.
112
+
113
+ You may want to choose **Let me select individual events** if you do not wish
114
+ to receive notifications for all supported events.
115
+
116
+ ### Start Codebot
117
+
118
+ After adding the webhook to your GitHub repository or organization, you can
119
+ manage your Codebot instance using the following commands:
120
+
121
+ ```
122
+ $ codebot core interactive # Starts Codebot in the foreground (interactively)
123
+ $ codebot core start # Starts Codebot in the background (as a daemon)
124
+ $ codebot core stop # Stops the active Codebot instance
125
+ ```
126
+
127
+ For more information, please consult the following commands:
128
+
129
+ ```
130
+ $ codebot help # General help
131
+ $ codebot help network # Commands for managing networks
132
+ $ codebot help integration # Commands for managing integrations
133
+ $ codebot help core # Commands for managing active instances
134
+ ```
135
+
136
+ The configuration is stored in `~/.codebot.yml`, but it is not recommended to
137
+ edit this file manually.
138
+
139
+ ## Environment Variables
140
+
141
+ Codebot supports the following environment variables:
142
+
143
+ * `CODEBOT_BIND` sets the address for the web server to bind to. When running
144
+ Codebot behind a local [gateway server][gateway], this environment variable
145
+ should be set to a loopback address like `127.0.0.1`.
146
+ * `CODEBOT_PORT` sets the port for the web server to listen on. This defaults
147
+ to `4567`. If you need to listen on a privileged port, please set up a
148
+ [gateway server][gateway] instead of trying to run Codebot as root.
149
+
150
+ ## Gateway Configuration
151
+
152
+ Codebot can optionally run behind a proxy, gateway server or load balancer.
153
+ This allows for additional configuration that would otherwise not be possible,
154
+ such as receiving webhooks over HTTPS.
155
+
156
+ When accessed through a gateway server, Codebot normally does not need to
157
+ listen on all interfaces. It is therefore recommended to set the `CODEBOT_BIND`
158
+ environment variable to a loopback address before starting Codebot:
159
+
160
+ ```
161
+ $ export CODEBOT_BIND='127.0.0.1'
162
+ ```
163
+
164
+ For larger instances it is recommended to install `thin` before proceeding, as
165
+ the standard `WEBrick` server is single-threaded by default.
166
+
167
+ ```
168
+ $ gem install thin
169
+ ```
170
+
171
+ ### lighttpd
172
+
173
+ lighttpd can be used as a gateway server using the `mod_proxy` module.
174
+
175
+ First, make sure that the `mod_proxy` module is loaded by adding the following
176
+ line to your `lighttpd.conf` file:
177
+
178
+ ```
179
+ server.modules += ( "mod_proxy" )
180
+ ```
181
+
182
+ Next, configure the module to redirect incoming requests to Codebot:
183
+
184
+ ```
185
+ # Forward requests for an entire domain or subdomain to Codebot
186
+ # Replace codebot.example.com with the subdomain to redirect to Codebot
187
+ # If CODEBOT_BIND is set, replace 127.0.0.1 with the address Codebot listens on
188
+ # If CODEBOT_PORT is set, replace 4567 with the port Codebot listens on
189
+ $HTTP["host"] == "codebot.example.com" {
190
+ proxy.server = ("/" => ( ( "host" => "127.0.0.1", "port" => 4567 ) ) )
191
+ }
192
+
193
+ # Alternatively, forward requests for a subdirectory to Codebot
194
+ # Replace /codebot with the subdirectory to redirect to Codebot
195
+ # If CODEBOT_BIND is set, replace 127.0.0.1 with the address Codebot listens on
196
+ # If CODEBOT_PORT is set, replace 4567 with the port Codebot listens on
197
+ proxy.header = ( "map-urlpath" => ( "/codebot" => "" ) )
198
+ proxy.server = ("/codebot" => ( ( "host" => "127.0.0.1", "port" => 4567 ) ) )
199
+ ```
200
+
201
+ That's it! You'll need to reload lighttpd for your changes to take effect.
202
+
203
+ If lighttpd has been configured correctly and Codebot is running, accessing the
204
+ gateway with a browser should yield a `Method not allowed` error.
205
+
206
+ ## Development
207
+
208
+ After checking out the repository, run `bundle install` to install dependencies.
209
+ You can also run `bin/console` for an interactive prompt.
210
+
211
+ During development it is recommended to set the `RACK_ENV` environment variable
212
+ to `development`. This causes the web server to listen only on the loopback
213
+ interface by default.
214
+
215
+ To install this gem onto your local machine, run `bundle exec rake install`.
216
+ To release a new version, update the version number in `metadata.rb` and run
217
+ `bundle exec rake release`, which will create a git tag for the version, push
218
+ git commits and tags, and push the `.gem` file to [RubyGems][rubygem].
219
+
220
+ ## Contributing
221
+
222
+ Bug reports and pull requests are welcome [on GitHub][github].
223
+ Please see the [CONTRIBUTING.md][contrib] for more information.
224
+
225
+ [github]: https://github.com/olabini/codebot "codebot on GitHub"
226
+ [contrib]: CONTRIBUTING.md "Guidelines for Contributors"
227
+ [rubygem]: https://rubygems.org/gems/codebot "codebot on RubyGems.org"
228
+ [newhook]: https://developer.github.com/webhooks/creating/#setting-up-a-webhook
229
+ [environ]: #environment-variables "Environment Variables"
230
+ [gateway]: #gateway-configuration "Gateway Configuration"