Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python

# Logs
*.log

# Virtual environments
venv/
env/
ENV/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ In most installations this packages are already installed, otherwise you easily

The configuration file (YSFReflector.ini) is based on the origin YSFReflector.ini of G4KLX's YSFReflector but with added new configuration-items. So If you know the old reflector-software - configuring this one would be straight forward.

## Best Practise Installation
## Best Practice Installation
For getting the best user experience it is recommended to configure your pYSFReflector with the following parameter in the YSFReflector.ini:

`FileRotate=0`
Expand Down
57 changes: 35 additions & 22 deletions YSFReflector
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,16 @@ def ElencoNodi(cl):
def TimeoutNodi(cl):
while True:
time.sleep(1)
# Create list of items to remove (avoid modifying list during iteration)
to_remove = []
for c in cl:
c[3] += 1
if (c[3] > 60):
printlog(1, 'Removing ' + c[2].ljust(10) + ' (' + c[0] + ':' + str(c[1]) + ') disappeared')
cl.remove(c)
to_remove.append(c)
# Remove items after iteration
for c in to_remove:
cl.remove(c)


def TimeoutTX(t, t_lock, r_lock, lista_lh, lista_lhd, t_out, t_react):
Expand Down Expand Up @@ -216,21 +221,22 @@ def scheduler():
def ckeck_wild_ptt(cs, tw, cnt, trea):
global W_PTT
global BLK_TMP
global SCHED
n = 0
tc = time.time()
W_PTT.append([cs, tc])
# Remove old entries (avoid modifying list during iteration)
W_PTT[:] = [r for r in W_PTT if r[1] >= (tc - tw)]
# Count occurrences of this callsign
for r in W_PTT:
if (r[1] < (tc - tw)):
W_PTT.remove(r)
else:
if (r[0] == cs):
n += 1
if (r[0] == cs):
n += 1
if (n >= cnt):
printlog(1, 'Wild-PTT ' + r[0])
if (not inlist(BLK_TMP, r[0])):
bisect.insort(BLK_TMP,r[0])
SCHED.append([r[0], 'RC', tc + trea])
printlog(1, 'Appended scheduled job: ' + r[0] + '/RC at time ' + time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(tc + trea)))
printlog(1, 'Wild-PTT ' + cs)
if (not inlist(BLK_TMP, cs)):
bisect.insort(BLK_TMP, cs)
SCHED.append([cs, 'RC', tc + trea])
printlog(1, 'Appended scheduled job: ' + cs + '/RC at time ' + time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(tc + trea)))


def canTrasmit(cs, re_en):
Expand Down Expand Up @@ -646,14 +652,19 @@ def RunServer(config):
s.sendto(b'YSFPREFLECTOR ',addr)

if (cmd == b'YSFU'):
client_to_remove = None
for c in clients:
if ((c[0] == addr[0]) and (c[1] == addr[1])):
printlog(1, 'Removing ' + c[2].ljust(10) + ' (' + c[0] + ':' + str(c[1]) + ') unlinked')
clients.remove(c)
client_to_remove = c
break
if client_to_remove is not None:
printlog(1, 'Removing ' + client_to_remove[2].ljust(10) + ' (' + client_to_remove[0] + ':' + str(client_to_remove[1]) + ') unlinked')
clients.remove(client_to_remove)

if ((cmd == b'YSFD') and (len(data) == 155)):
[id_corr, gw_corr] = getidgw(clients, addr)
tx_ok = True
block_r = ''
if (tx[0] == 0):
if (inlist(GW_BL, gw_corr) or inlist(GW_LK, gw_corr)):
tx_ok = False
Expand Down Expand Up @@ -825,7 +836,7 @@ def printlog(log_level, mess):
global debug

if file_rotate == "1":
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d')) + '.log'
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d')) + '.log'
else:
log_file = log_basename + '.log'
try:
Expand All @@ -836,17 +847,19 @@ def printlog(log_level, mess):
except:
pass

str_log = None
if isinstance(log_level, int):
if file_level <= log_level:
str_log = check_string('M: ' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
str_log = check_string('M: ' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
else:
if log_level == "d" and debug == 1:
str_log = check_string('D: ' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
try:
filelog.write(str_log + '\n')
filelog.flush()
except:
pass
str_log = check_string('D: ' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
if str_log is not None:
try:
filelog.write(str_log + '\n')
filelog.flush()
except:
pass


def hex_dump(data):
Expand Down Expand Up @@ -897,7 +910,7 @@ debug = config[13]

### log
if file_rotate == "1":
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d')) + '.log'
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d')) + '.log'
else:
log_file = log_basename + '.log'
try:
Expand Down