Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
maubot
gitlab
Commits
cac3cb74
"README.md" did not exist on "37558d5e4cd22ec8f120d2c0fbb8c9842d6dd131"
Unverified
Commit
cac3cb74
authored
5 years ago
by
Lorenz Steinert
Browse files
Options
Downloads
Patches
Plain Diff
enable ipv6 and return response to gitlab asap
parent
fd424375
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gitlab/__init__.py
+20
-19
20 additions, 19 deletions
gitlab/__init__.py
with
20 additions
and
19 deletions
gitlab/__init__.py
+
20
−
19
View file @
cac3cb74
from
typing
import
Type
import
asyncio
from
aiohttp
import
web
from
typing
import
List
,
Type
from
mautrix.types
import
EventType
from
aiohttp
import
web
from
mautrix.util.config
import
BaseProxyConfig
,
ConfigUpdateHelper
from
maubot
import
Plugin
,
MessageEvent
from
maubot.handlers
import
event
from
maubot
import
Plugin
class
Config
(
BaseProxyConfig
):
...
...
@@ -23,36 +21,39 @@ class Gitlab(Plugin):
routes
=
web
.
RouteTableDef
()
async
def
post_handler
(
self
,
request
):
if
not
request
.
headers
[
'
X-Gitlab-Token
'
]
==
self
.
config
[
'
secret
'
]:
self
.
log
.
warn
(
'
unauthorised access
'
)
return
web
.
Response
()
async
def
process_hook
(
self
,
request
:
web
.
Request
)
->
None
:
self
.
log
.
debug
(
str
(
request
))
self
.
log
.
debug
(
str
(
request
.
query
[
'
room
'
]))
await
self
.
client
.
send_text
(
request
.
query
[
'
room
'
],
str
(
request
))
async
def
post_handler
(
self
,
request
:
web
.
Request
)
->
web
.
Response
:
if
not
request
.
headers
[
'
X-Gitlab-Token
'
]
==
self
.
config
[
'
secret
'
]:
return
web
.
Response
(
status
=
403
)
self
.
task_list
.
append
(
asyncio
.
create_task
(
self
.
process_hook
(
request
)))
return
web
.
Response
()
async
def
start
(
self
)
->
None
:
self
.
config
.
load_and_update
()
self
.
task_list
:
List
[
asyncio
.
Task
]
=
[]
self
.
app
=
web
.
Application
()
self
.
app
.
add_routes
([
web
.
post
(
self
.
config
[
'
path
'
],
self
.
post_handler
)])
self
.
runner
=
web
.
AppRunner
(
self
.
app
)
await
self
.
runner
.
setup
()
await
self
.
runner
.
setup
()
site
=
web
.
TCPSite
(
self
.
runner
,
'
0.0.0.0
'
,
self
.
config
[
'
port
'
])
await
site
.
start
()
self
.
sitev4
=
web
.
TCPSite
(
self
.
runner
,
'
0.0.0.0
'
,
self
.
config
[
'
port
'
])
self
.
sitev6
=
web
.
TCPSite
(
self
.
runner
,
'
::
'
,
self
.
config
[
'
port
'
])
await
self
.
sitev4
.
start
()
await
self
.
sitev6
.
start
()
async
def
stop
(
self
)
->
None
:
for
task
in
self
.
task_list
:
await
asyncio
.
wait_for
(
task
,
timeout
=
1.0
)
await
self
.
runner
.
cleanup
()
@event.on
(
EventType
.
ROOM_MESSAGE
)
async
def
handler
(
self
,
event
:
MessageEvent
)
->
None
:
if
event
.
sender
!=
self
.
client
.
mxid
:
for
ii
in
[
'
path
'
,
'
port
'
,
'
secret
'
,
'
base_command
'
]:
await
self
.
client
.
send_text
(
event
.
room_id
,
str
(
self
.
config
[
ii
]))
@classmethod
def
get_config_class
(
cls
)
->
Type
[
BaseProxyConfig
]:
return
Config
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment