Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
irker
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
iDB
irker
Commits
32e3b257
Commit
32e3b257
authored
12 years ago
by
Eric S. Raymond
Browse files
Options
Downloads
Patches
Plain Diff
Fully interpret CHANLIMIT.
parent
5eec81d4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
irker
+31
-7
31 additions, 7 deletions
irker
with
31 additions
and
7 deletions
irker
+
31
−
7
View file @
32e3b257
...
...
@@ -86,7 +86,7 @@ class Connection:
self
.
last_xmit
=
time
.
time
()
self
.
last_ping
=
time
.
time
()
self
.
channels_joined
=
[]
self
.
channel_
max
=
CHANNEL_MAX
self
.
channel_
limits
=
{}
# The consumer thread
self
.
queue
=
Queue
.
Queue
()
self
.
thread
=
threading
.
Thread
(
target
=
self
.
dequeue
)
...
...
@@ -183,9 +183,16 @@ class Connection:
def
joined_to
(
self
,
channel
):
"
Is this connection joined to the specified channel?
"
return
channel
in
self
.
channels_joined
def
accepting
(
self
):
"
Can this connection accept new channel joins?
"
return
len
(
self
.
channels_joined
)
<
self
.
channel_max
def
accepting
(
self
,
channel
):
"
Can this connection accept a join of this channel?
"
if
self
.
channel_limits
:
match_count
=
0
for
already
in
self
.
channels_joined
:
if
already
[
0
]
==
channel
[
0
]:
match_count
+=
1
return
match_count
<
self
.
channel_limits
.
get
(
channel
[
0
],
CHANNEL
+
MAX
)
else
:
return
len
(
self
.
channels_joined
)
<
CHANNEL_MAX
class
Target
():
"
Represent a transmission target.
"
...
...
@@ -212,7 +219,7 @@ class Dispatcher:
"
Dispatch messages for our server-port combination.
"
self
.
connections
=
[
x
for
x
in
self
.
connections
if
x
.
live
()]
eligibles
=
[
x
for
x
in
self
.
connections
if
x
.
joined_to
(
channel
)]
\
or
[
x
for
x
in
self
.
connections
if
x
.
accepting
()]
or
[
x
for
x
in
self
.
connections
if
x
.
accepting
(
channel
)]
if
not
eligibles
:
newconn
=
Connection
(
self
.
irker
,
self
.
servername
,
...
...
@@ -264,11 +271,28 @@ class Irker:
def
_handle_features
(
self
,
connection
,
event
):
"
Determine if and how we can set deaf mode.
"
if
connection
.
context
:
cxt
=
connection
.
context
for
lump
in
event
.
arguments
():
if
lump
.
startswith
(
"
DEAF=
"
):
connection
.
mode
(
connection
.
context
.
nickname
(),
"
+
"
+
lump
[
5
:])
connection
.
mode
(
cxt
.
nickname
(),
"
+
"
+
lump
[
5
:])
elif
lump
.
startswith
(
"
MAXCHANNELS=
"
):
m
=
int
(
lump
[
12
:])
for
pref
in
"
#&+
"
:
cxt
.
channel_limits
[
pref
]
=
m
self
.
debug
(
1
,
"
%s maxchannels is %d
"
\
%
(
connection
.
server
,
m
))
elif
lump
.
startswith
(
"
CHANLIMIT=#:
"
):
connection
.
context
.
channel_max
=
int
(
lump
[
12
:])
limits
=
lump
[
10
:].
split
(
"
,
"
)
try
:
for
token
in
limits
:
(
prefixes
,
limit
)
=
token
.
split
(
"
:
"
)
limit
=
int
(
limit
)
for
c
in
prefixes
:
cxt
.
channel_limits
[
c
]
=
limit
self
.
debug
(
1
,
"
%s channel limit map is %s
"
\
%
(
connection
.
server
,
cxt
.
channel_limits
))
except
ValueError
:
self
.
logerr
(
"
ill-formed CHANLIMIT property
"
)
def
drop_server
(
self
,
servername
,
port
):
"
Drop a server out of the server map.
"
del
self
.
servers
[(
servername
,
port
)]
...
...
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