psiphon 2.0.1__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: psiphon
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: Foreground native Psiphon packet tunnel and explicit local proxy for Linux
5
5
  Author: KpihX
6
6
  Author-email: KpihX <kapoivha@gmail.com>
@@ -69,6 +69,11 @@ the worker refuses before mutations. Cancellation starts no supervisor or route
69
69
  For agent-operated privilege, launch connect only in an armed tmux pane in the
70
70
  agent's current window. No sudo or privileged operation runs in offline checks.
71
71
 
72
+ Logs live in `$XDG_STATE_HOME/psiphon/psiphon.log` (default
73
+ `~/.local/state/psiphon/`). Before a new connection, a 2 MiB log rotates through
74
+ four numbered prior logs (`.1` to `.4`), bounding retained log storage to about
75
+ 10 MiB. The oldest retained log is discarded on the next rotation.
76
+
72
77
  **Escalation trust:** sudo approves this local Python interpreter and installed
73
78
  package, including an editable checkout if that is what you installed. They may
74
79
  be user-writable. `-I` avoids ambient PYTHONPATH/user-site, but does not make that
@@ -52,6 +52,11 @@ the worker refuses before mutations. Cancellation starts no supervisor or route
52
52
  For agent-operated privilege, launch connect only in an armed tmux pane in the
53
53
  agent's current window. No sudo or privileged operation runs in offline checks.
54
54
 
55
+ Logs live in `$XDG_STATE_HOME/psiphon/psiphon.log` (default
56
+ `~/.local/state/psiphon/`). Before a new connection, a 2 MiB log rotates through
57
+ four numbered prior logs (`.1` to `.4`), bounding retained log storage to about
58
+ 10 MiB. The oldest retained log is discarded on the next rotation.
59
+
55
60
  **Escalation trust:** sudo approves this local Python interpreter and installed
56
61
  package, including an editable checkout if that is what you installed. They may
57
62
  be user-writable. `-I` avoids ambient PYTHONPATH/user-site, but does not make that
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "psiphon"
3
- version = "2.0.1"
3
+ version = "2.0.2"
4
4
  description = "Foreground native Psiphon packet tunnel and explicit local proxy for Linux"
5
5
  readme = "README.md"
6
6
  license = "BUSL-1.1"
@@ -50,6 +50,8 @@ RUNTIME_DIR = _runtime / f"psiphon-{os.getuid()}"
50
50
  ACTIVE_CONFIG = CONFIG_DIR / "psiphon.config"
51
51
  PID_FILE = RUNTIME_DIR / "psiphon.pid"
52
52
  LOG_FILE = STATE_DIR / "psiphon.log"
53
+ LOG_MAX_BYTES = 2 * 1024 * 1024
54
+ LOG_BACKUPS = 4
53
55
  SESSION_FILE = RUNTIME_DIR / "session.json"
54
56
  DATA_DIR = CACHE_DIR / "core" # signed server-list cache and tunnel-core datastore
55
57
 
@@ -113,6 +113,23 @@ def notice_state(offset: int = 0) -> dict[str, Any]:
113
113
  return state
114
114
 
115
115
 
116
+ def rotate_log() -> None:
117
+ """Keep a bounded local history before opening a new connection log."""
118
+ if (
119
+ not config.LOG_FILE.exists()
120
+ or config.LOG_FILE.stat().st_size < config.LOG_MAX_BYTES
121
+ ):
122
+ return
123
+ oldest = config.LOG_FILE.with_name(f"{config.LOG_FILE.name}.{config.LOG_BACKUPS}")
124
+ if oldest.exists():
125
+ oldest.unlink()
126
+ for number in range(config.LOG_BACKUPS - 1, 0, -1):
127
+ source = config.LOG_FILE.with_name(f"{config.LOG_FILE.name}.{number}")
128
+ if source.exists():
129
+ source.replace(source.with_name(f"{config.LOG_FILE.name}.{number + 1}"))
130
+ config.LOG_FILE.replace(config.LOG_FILE.with_name(f"{config.LOG_FILE.name}.1"))
131
+
132
+
116
133
  def process_identity(pid: int) -> dict[str, str]:
117
134
  proc = Path(f"/proc/{pid}")
118
135
  stat = (proc / "stat").read_text().rsplit(") ", 1)[1].split()
@@ -170,7 +187,8 @@ def connected(region: str, proxy: bool, interface: str | None, wait_s: float):
170
187
  elif interface:
171
188
  uplink = interface
172
189
  engine.write_config(region, proxy)
173
- # Create a private log before the worker opens it; never truncate history.
190
+ # Create a private log before the worker opens it; preserve bounded history.
191
+ rotate_log()
174
192
  fd = os.open(
175
193
  config.LOG_FILE,
176
194
  os.O_APPEND | os.O_CREAT | os.O_WRONLY | os.O_NOFOLLOW,
File without changes
File without changes
File without changes
File without changes
File without changes