Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

feat(ui): pair and sync without a server

baiyuze52826d28e2d1
diff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dart
index 63af45c..7cb35d3 100644
--- a/ui/lib/app_state.dart
+++ b/ui/lib/app_state.dart
@@ -12,6 +12,12 @@ import 'gen/copysync/v1/daemon.pbgrpc.dart' show DaemonServiceClient;
/// daemon 连接的生命周期状态。
enum LinkState { connecting, online, offline }
+/// 生成的配对码,以及本机的局域网地址(不在同一网段时对方要输入)。
+typedef PairingCode = ({String code, List<String> addresses});
+
+/// 配对失败的原因。后台服务把原因写在错误消息开头(见 rpc/server.go 的 pairingStatus)。
+enum PairingFailure { notFound, wrongCode, codeExpired, badAddress, noChannel, other }
+
/// 应用的单一状态源。
///
/// 所有与 daemon 的交互都经过这里:页面只读状态、调方法,不直接碰 gRPC。
@@ -60,6 +66,13 @@ class AppState extends ChangeNotifier {
bool get isOnline => _link == LinkState.online;
int get onlinePeerCount => _peers.where((p) => p.online).length;
+ /// 设置里填了服务器地址。没填时只在局域网里同步,不算异常。
+ bool get serverConfigured => _status?.serverConfigured ?? false;
+ bool get lanEnabled => _status?.lanEnabled ?? false;
+
+ /// macOS 拦下了发往局域网的包:用户还没允许「本地网络」权限。
+ bool get lanBlocked => _status?.lanBlocked ?? false;
+
@override
void dispose() {
_retry?.cancel();
@@ -307,15 +320,18 @@ class AppState extends ChangeNotifier {
return c.client;
}
- Future<String> createPairingCode() async {
+ Future<PairingCode> createPairingCode() async {
final resp = await _client.createPairingCode(Empty());
- return resp.code;
+ return (code: resp.code, addresses: resp.lanAddresses.toList());
}
/// 兑换配对码,返回待核对指纹的对端信息。
- Future<Device> redeemPairingCode(String code) async {
+ /// [address] 是对方配对码下面显示的地址,不在同一网段时才需要。
+ Future<Device> redeemPairingCode(String code, {String address = ''}) async {
final resp = await _client.redeemPairingCode(
- RedeemPairingCodeRequest(code: code.trim().toUpperCase()),
+ RedeemPairingCodeRequest(code: code.trim().toUpperCase(), address: address.trim()),
+ // 在局域网里找对方要几秒,找不到再去服务器上兑换
+ options: CallOptions(timeout: const Duration(seconds: 30)),
);
final peer = resp.peer..pairingSession = resp.pairingSession;
_setPendingPairing(peer);
@@ -346,6 +362,13 @@ class AppState extends ChangeNotifier {
notifyListeners();
}
+ /// 手动告诉后台服务某台设备的地址:跨网段、或两边都换了地址时用。
+ Future<void> setDeviceAddress(String deviceId, String address) =>
+ _client.setDeviceAddress(SetDeviceAddressRequest(deviceId: deviceId, address: address.trim()));
+
+ /// macOS 打开「本地网络」设置;Windows 申请管理员权限放行防火墙。
+ Future<void> requestLocalNetworkPermission() => _client.requestLocalNetworkPermission(Empty());
+
Future<void> unpair(String deviceId) async {
await _client.unpair(UnpairRequest(deviceId: deviceId));
_peers = _peers.where((p) => p.id != deviceId).toList();
@@ -400,4 +423,18 @@ class AppState extends ChangeNotifier {
}
static String describeError(Object e) => _describe(e);
+
+ /// 从配对出错的消息里取出原因。
+ static PairingFailure pairingFailure(Object e) {
+ if (e is! GrpcError) return PairingFailure.other;
+ final reason = (e.message ?? '').split(':').first.trim();
+ return switch (reason) {
+ 'not_found' => PairingFailure.notFound,
+ 'wrong_code' => PairingFailure.wrongCode,
+ 'code_expired' => PairingFailure.codeExpired,
+ 'bad_address' => PairingFailure.badAddress,
+ 'no_channel' => PairingFailure.noChannel,
+ _ => PairingFailure.other,
+ };
+ }
}
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
index 8870f0c..e39ba48 100644
--- a/ui/lib/l10n/app_en.arb
+++ b/ui/lib/l10n/app_en.arb
@@ -5,7 +5,10 @@
"navSettings": "Settings",
"linkConnecting": "Connecting…",
"linkServiceNotRunning": "Service not running",
- "linkNoServer": "No server connection",
+ "linkLanMode": "Looking for devices on this network",
+ "linkServerUnreachable": "Can't reach the server; syncing on this network",
+ "linkNothingOn": "Local network discovery is off and no server is set",
+ "linkLanBlocked": "macOS is blocking the local network",
"linkOnlinePeers": "{count, plural, =1{1 device online} other{{count} devices online}}",
"@linkOnlinePeers": {
"placeholders": {
@@ -237,8 +240,7 @@
}
},
"noDevicesTitle": "No paired devices yet",
- "noDevicesBody": "Open CopySync on your other computer and link the two with a 6-character pairing code.",
- "noDevicesNeedServer": "Connect to a signaling server in Settings before pairing.",
+ "noDevicesBody": "Open CopySync on your other computer and link the two with a 6-character pairing code. On the same network, nothing else is needed.",
"pairedDevices": "Paired devices",
"pairedFootnote": "Direct: data goes straight between the two devices. Relay: when the network blocks a direct path, data goes through your server and stays end-to-end encrypted.",
"offline": "Offline",
@@ -260,6 +262,33 @@
"unpairBody": "The two devices will stop syncing. To sync again, you'll need to pair them and check the fingerprints again.",
"unpair": "Unpair",
"unpaired": "Unpaired",
+ "enterAddressEllipsis": "Enter its address…",
+ "setAddressTitle": "Address of “{name}”",
+ "@setAddressTitle": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "setAddressBody": "Use this when the two devices are on different subnets, or both changed addresses. Enter the address shown on “{name}” under Add device → Show a code.",
+ "@setAddressBody": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "addressSaved": "Looking for it at that address",
+ "lanBlockedTitle": "macOS is blocking the local network",
+ "lanBlockedBody": "Turn on CopySync Daemon in System Settings → Privacy & Security → Local Network. Until then, {device} can't connect to devices on this network.",
+ "@lanBlockedBody": {
+ "placeholders": {
+ "device": {
+ "type": "String"
+ }
+ }
+ },
"generateCode": "Show a code",
"enterCode": "Enter a code",
"codeFailedTitle": "Couldn't create a pairing code",
@@ -275,6 +304,17 @@
}
},
"codeInvalid": "A pairing code is 6 letters or digits",
+ "localAddress": "Address",
+ "addressHint": "On a different subnet? Enter this address on the other device as well.",
+ "addressCopied": "Address copied",
+ "differentSubnet": "On a different subnet?",
+ "peerAddress": "Address shown under the code",
+ "pairNotFound": "Couldn't find that device. If it's on a different subnet, enter the address shown under its code.",
+ "pairNotFoundAddress": "Nothing answered at that address. Check the address and that the other device is still showing its code. A firewall on that device may also be blocking it.",
+ "codeWrong": "That code isn't right, or it has expired",
+ "codeExpired": "This code has expired. Show a new one on the other device.",
+ "addressInvalid": "That address isn't valid. Enter something like 192.168.1.20.",
+ "pairNoChannel": "Turn on local network discovery or set a server in Settings first.",
"enterCodeShown": "Enter the code shown on your other device",
"pairingDone": "Paired",
"pairingRejected": "Pairing declined",
@@ -297,10 +337,10 @@
},
"rejectMismatch": "Mismatch, decline",
"confirmMatch": "They match, pair",
- "server": "Server",
- "serverFootnote": "The server only helps devices find each other and set up a direct connection. It can't see what they send.",
+ "server": "Server (optional)",
+ "serverFootnote": "Only needed to sync between different networks, such as home and office. Devices on the same network connect without it. The server only helps devices find each other and can't see what they send.",
"signalingUrl": "Signaling server",
- "signalingUrlDesc": "Press Return to save; it reconnects right away",
+ "signalingUrlDesc": "Press Return to save. Leave it empty to sync on this network only.",
"signalingUrlPlaceholder": "ws://server-address:8787/signal",
"publicStun": "Probe with public servers",
"publicStunDesc": "On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.",
@@ -309,6 +349,19 @@
"disconnectedDesc": "Can't reach the server. Check the address and that the server is running.",
"connected": "Connected",
"notConnected": "Not connected",
+ "notSet": "Not set",
+ "notSetDesc": "Syncing with devices on this network only",
+ "serverCleared": "Server removed. Syncing on this network only.",
+ "localNetwork": "Local network",
+ "lanFootnote": "Uses UDP port 8788. If the devices are on different subnets, enter the other device's address when pairing.",
+ "lanDiscovery": "Find devices on this network",
+ "lanDiscoveryDesc": "Pair and sync without a server. Others on the network only see an anonymous entry that changes daily.",
+ "macLocalNetwork": "Local Network access",
+ "macLocalNetworkDesc": "macOS asks once whether CopySync may connect to devices on your network. If you declined, turn on CopySync Daemon there.",
+ "allowLan": "Windows Firewall",
+ "allowLanDesc": "Allow this when other devices can't reach this one, for example when pairing from another subnet. Asks for administrator approval once.",
+ "allow": "Allow",
+ "allowLanDone": "Allowed. Other devices can now reach this one.",
"deviceName": "Device name",
"deviceNameDesc": "Shown in the list on your other devices",
"language": "Language",
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
index 634769b..2d61739 100644
--- a/ui/lib/l10n/app_ja.arb
+++ b/ui/lib/l10n/app_ja.arb
@@ -5,7 +5,10 @@
"navSettings": "設定",
"linkConnecting": "接続中…",
"linkServiceNotRunning": "サービス停止中",
- "linkNoServer": "サーバーに未接続",
+ "linkLanMode": "このネットワークでデバイスを探しています",
+ "linkServerUnreachable": "サーバーに接続できません。このネットワーク内では同期します",
+ "linkNothingOn": "ローカルネットワークの検出がオフで、サーバーも未設定です",
+ "linkLanBlocked": "macOS がローカルネットワークをブロックしています",
"linkOnlinePeers": "{count} 台がオンライン",
"linkServerConnected": "サーバーに接続済み",
"linkConnectionLost": "接続が切れました:{detail}",
@@ -89,8 +92,7 @@
"addDevice": "デバイスを追加",
"thisDeviceFootnote": "ペアリング時、{both}に同じ 2 行のセキュリティ指紋(このデバイスと相手のもの)が表示されます。1 文字ずつ一致を確かめてから確定してください。",
"noDevicesTitle": "ペアリングしたデバイスはまだありません",
- "noDevicesBody": "もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。",
- "noDevicesNeedServer": "ペアリングの前に、「設定」でシグナリングサーバーに接続してください。",
+ "noDevicesBody": "もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。同じネットワーク内なら、ほかに準備はいりません。",
"pairedDevices": "ペアリング済みのデバイス",
"pairedFootnote": "直接接続:データは 2 台のデバイス間で直接やり取りされます。中継:直接つながらないネットワークでは、あなたのサーバーを経由します。内容はエンドツーエンドで暗号化されたままです。",
"offline": "オフライン",
@@ -105,6 +107,12 @@
"unpairBody": "2 台のデバイスは同期しなくなります。再開するには、もう一度ペアリングして指紋を確かめる必要があります。",
"unpair": "ペアリングを解除",
"unpaired": "ペアリングを解除しました",
+ "enterAddressEllipsis": "アドレスを入力…",
+ "setAddressTitle": "「{name}」のアドレス",
+ "setAddressBody": "2 台が別のサブネットにある場合や、どちらもアドレスが変わった場合に使います。「{name}」の「デバイスを追加 → コードを表示」に表示されるアドレスを入力してください。",
+ "addressSaved": "そのアドレスで探しています",
+ "lanBlockedTitle": "macOS がローカルネットワークへのアクセスをブロックしています",
+ "lanBlockedBody": "「システム設定 → プライバシーとセキュリティ → ローカルネットワーク」で CopySync Daemon をオンにしてください。オンにするまで、{device}は同じネットワークのデバイスに接続できません。",
"generateCode": "コードを表示",
"enterCode": "コードを入力",
"codeFailedTitle": "ペアリングコードを作成できませんでした",
@@ -113,6 +121,17 @@
"codeHint": "クリックでコピー。有効期間は 5 分です。",
"afterEnterFootnote": "入力されると、{both}に同じ 2 行のセキュリティ指紋が表示されます。一致を確かめてから確定してください。",
"codeInvalid": "ペアリングコードは 6 桁の英数字です",
+ "localAddress": "アドレス",
+ "addressHint": "別のサブネットにある場合は、もう一台でこのアドレスも入力します",
+ "addressCopied": "アドレスをコピーしました",
+ "differentSubnet": "別のサブネットにありますか?",
+ "peerAddress": "コードの下に表示されたアドレス",
+ "pairNotFound": "そのデバイスが見つかりません。別のサブネットにある場合は、コードの下に表示されたアドレスを入力してください。",
+ "pairNotFoundAddress": "そのアドレスから応答がありません。アドレスと、相手がまだコードを表示しているかを確認してください。相手のファイアウォールがブロックしている可能性もあります。",
+ "codeWrong": "コードが違うか、有効期限が切れています",
+ "codeExpired": "このコードは無効になりました。もう一台で新しいコードを表示してください。",
+ "addressInvalid": "アドレスの形式が正しくありません。192.168.1.20 のように入力してください。",
+ "pairNoChannel": "先に「設定」でローカルネットワークの検出をオンにするか、サーバーを設定してください。",
"enterCodeShown": "もう一台のデバイスに表示されたコードを入力してください",
"pairingDone": "ペアリングしました",
"pairingRejected": "ペアリングを拒否しました",
@@ -121,10 +140,10 @@
"verifyBody": "{both}に表示された 2 行は完全に同じはずです。1 文字でも違う場合は、第三者が通信を改ざんしている可能性があるため、拒否してください。",
"rejectMismatch": "不一致、拒否",
"confirmMatch": "一致、ペアリング",
- "server": "サーバー",
- "serverFootnote": "サーバーはデバイス同士を見つけ、直接接続を取り持つだけです。やり取りする内容は見えません。",
+ "server": "サーバー(任意)",
+ "serverFootnote": "家と会社のように、別々のネットワーク間で同期するときだけ必要です。同じネットワーク内のデバイスはサーバーなしで直接つながります。サーバーはデバイス同士を引き合わせるだけで、やり取りする内容は見えません。",
"signalingUrl": "シグナリングサーバー",
- "signalingUrlDesc": "Enter で保存し、すぐに再接続します",
+ "signalingUrlDesc": "Enter で保存。空欄にするとこのネットワーク内だけで同期します",
"signalingUrlPlaceholder": "ws://サーバーアドレス:8787/signal",
"publicStun": "公開サーバーで出口を調べる",
"publicStunDesc": "複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。",
@@ -133,6 +152,19 @@
"disconnectedDesc": "サーバーに接続できません。アドレスとサーバーの稼働を確認してください。",
"connected": "接続済み",
"notConnected": "未接続",
+ "notSet": "未設定",
+ "notSetDesc": "同じネットワークのデバイスとだけ同期します",
+ "serverCleared": "サーバーを削除しました。このネットワーク内だけで同期します",
+ "localNetwork": "ローカルネットワーク",
+ "lanFootnote": "UDP ポート 8788 を使います。2 台が別のサブネットにある場合は、ペアリング時に相手のアドレスを入力します。",
+ "lanDiscovery": "このネットワークでデバイスを探す",
+ "lanDiscoveryDesc": "サーバーなしでペアリングと同期ができます。ネットワーク上の他の人には、毎日変わる匿名の識別子しか見えません",
+ "macLocalNetwork": "ローカルネットワークへのアクセス",
+ "macLocalNetworkDesc": "CopySync がネットワーク上のデバイスに接続してよいか、macOS が一度だけ確認します。拒否した場合は、そこで CopySync Daemon をオンにしてください",
+ "allowLan": "Windows ファイアウォール",
+ "allowLanDesc": "他のデバイスからこのデバイスに接続できないとき(別のサブネットからのペアリングなど)に許可します。管理者の承認を 1 回求めます",
+ "allow": "許可",
+ "allowLanDone": "許可しました。他のデバイスからこのデバイスに接続できます。",
"deviceName": "デバイス名",
"deviceNameDesc": "他のデバイスの一覧に表示されます",
"language": "言語",
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
index 027c20e..df2714b 100644
--- a/ui/lib/l10n/app_localizations.dart
+++ b/ui/lib/l10n/app_localizations.dart
@@ -130,11 +130,29 @@ abstract class AppLocalizations {
/// **'Service not running'**
String get linkServiceNotRunning;
- /// No description provided for @linkNoServer.
+ /// No description provided for @linkLanMode.
///
/// In en, this message translates to:
- /// **'No server connection'**
- String get linkNoServer;
+ /// **'Looking for devices on this network'**
+ String get linkLanMode;
+
+ /// No description provided for @linkServerUnreachable.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t reach the server; syncing on this network'**
+ String get linkServerUnreachable;
+
+ /// No description provided for @linkNothingOn.
+ ///
+ /// In en, this message translates to:
+ /// **'Local network discovery is off and no server is set'**
+ String get linkNothingOn;
+
+ /// No description provided for @linkLanBlocked.
+ ///
+ /// In en, this message translates to:
+ /// **'macOS is blocking the local network'**
+ String get linkLanBlocked;
/// No description provided for @linkOnlinePeers.
///
@@ -637,15 +655,9 @@ abstract class AppLocalizations {
/// No description provided for @noDevicesBody.
///
/// In en, this message translates to:
- /// **'Open CopySync on your other computer and link the two with a 6-character pairing code.'**
+ /// **'Open CopySync on your other computer and link the two with a 6-character pairing code. On the same network, nothing else is needed.'**
String get noDevicesBody;
- /// No description provided for @noDevicesNeedServer.
- ///
- /// In en, this message translates to:
- /// **'Connect to a signaling server in Settings before pairing.'**
- String get noDevicesNeedServer;
-
/// No description provided for @pairedDevices.
///
/// In en, this message translates to:
@@ -730,6 +742,42 @@ abstract class AppLocalizations {
/// **'Unpaired'**
String get unpaired;
+ /// No description provided for @enterAddressEllipsis.
+ ///
+ /// In en, this message translates to:
+ /// **'Enter its address…'**
+ String get enterAddressEllipsis;
+
+ /// No description provided for @setAddressTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Address of “{name}”'**
+ String setAddressTitle(String name);
+
+ /// No description provided for @setAddressBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Use this when the two devices are on different subnets, or both changed addresses. Enter the address shown on “{name}” under Add device → Show a code.'**
+ String setAddressBody(String name);
+
+ /// No description provided for @addressSaved.
+ ///
+ /// In en, this message translates to:
+ /// **'Looking for it at that address'**
+ String get addressSaved;
+
+ /// No description provided for @lanBlockedTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'macOS is blocking the local network'**
+ String get lanBlockedTitle;
+
+ /// No description provided for @lanBlockedBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on CopySync Daemon in System Settings → Privacy & Security → Local Network. Until then, {device} can\'t connect to devices on this network.'**
+ String lanBlockedBody(String device);
+
/// No description provided for @generateCode.
///
/// In en, this message translates to:
@@ -778,6 +826,72 @@ abstract class AppLocalizations {
/// **'A pairing code is 6 letters or digits'**
String get codeInvalid;
+ /// No description provided for @localAddress.
+ ///
+ /// In en, this message translates to:
+ /// **'Address'**
+ String get localAddress;
+
+ /// No description provided for @addressHint.
+ ///
+ /// In en, this message translates to:
+ /// **'On a different subnet? Enter this address on the other device as well.'**
+ String get addressHint;
+
+ /// No description provided for @addressCopied.
+ ///
+ /// In en, this message translates to:
+ /// **'Address copied'**
+ String get addressCopied;
+
+ /// No description provided for @differentSubnet.
+ ///
+ /// In en, this message translates to:
+ /// **'On a different subnet?'**
+ String get differentSubnet;
+
+ /// No description provided for @peerAddress.
+ ///
+ /// In en, this message translates to:
+ /// **'Address shown under the code'**
+ String get peerAddress;
+
+ /// No description provided for @pairNotFound.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t find that device. If it\'s on a different subnet, enter the address shown under its code.'**
+ String get pairNotFound;
+
+ /// No description provided for @pairNotFoundAddress.
+ ///
+ /// In en, this message translates to:
+ /// **'Nothing answered at that address. Check the address and that the other device is still showing its code. A firewall on that device may also be blocking it.'**
+ String get pairNotFoundAddress;
+
+ /// No description provided for @codeWrong.
+ ///
+ /// In en, this message translates to:
+ /// **'That code isn\'t right, or it has expired'**
+ String get codeWrong;
+
+ /// No description provided for @codeExpired.
+ ///
+ /// In en, this message translates to:
+ /// **'This code has expired. Show a new one on the other device.'**
+ String get codeExpired;
+
+ /// No description provided for @addressInvalid.
+ ///
+ /// In en, this message translates to:
+ /// **'That address isn\'t valid. Enter something like 192.168.1.20.'**
+ String get addressInvalid;
+
+ /// No description provided for @pairNoChannel.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on local network discovery or set a server in Settings first.'**
+ String get pairNoChannel;
+
/// No description provided for @enterCodeShown.
///
/// In en, this message translates to:
@@ -829,13 +943,13 @@ abstract class AppLocalizations {
/// No description provided for @server.
///
/// In en, this message translates to:
- /// **'Server'**
+ /// **'Server (optional)'**
String get server;
/// No description provided for @serverFootnote.
///
/// In en, this message translates to:
- /// **'The server only helps devices find each other and set up a direct connection. It can\'t see what they send.'**
+ /// **'Only needed to sync between different networks, such as home and office. Devices on the same network connect without it. The server only helps devices find each other and can\'t see what they send.'**
String get serverFootnote;
/// No description provided for @signalingUrl.
@@ -847,7 +961,7 @@ abstract class AppLocalizations {
/// No description provided for @signalingUrlDesc.
///
/// In en, this message translates to:
- /// **'Press Return to save; it reconnects right away'**
+ /// **'Press Return to save. Leave it empty to sync on this network only.'**
String get signalingUrlDesc;
/// No description provided for @signalingUrlPlaceholder.
@@ -898,6 +1012,84 @@ abstract class AppLocalizations {
/// **'Not connected'**
String get notConnected;
+ /// No description provided for @notSet.
+ ///
+ /// In en, this message translates to:
+ /// **'Not set'**
+ String get notSet;
+
+ /// No description provided for @notSetDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Syncing with devices on this network only'**
+ String get notSetDesc;
+
+ /// No description provided for @serverCleared.
+ ///
+ /// In en, this message translates to:
+ /// **'Server removed. Syncing on this network only.'**
+ String get serverCleared;
+
+ /// No description provided for @localNetwork.
+ ///
+ /// In en, this message translates to:
+ /// **'Local network'**
+ String get localNetwork;
+
+ /// No description provided for @lanFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'Uses UDP port 8788. If the devices are on different subnets, enter the other device\'s address when pairing.'**
+ String get lanFootnote;
+
+ /// No description provided for @lanDiscovery.
+ ///
+ /// In en, this message translates to:
+ /// **'Find devices on this network'**
+ String get lanDiscovery;
+
+ /// No description provided for @lanDiscoveryDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Pair and sync without a server. Others on the network only see an anonymous entry that changes daily.'**
+ String get lanDiscoveryDesc;
+
+ /// No description provided for @macLocalNetwork.
+ ///
+ /// In en, this message translates to:
+ /// **'Local Network access'**
+ String get macLocalNetwork;
+
+ /// No description provided for @macLocalNetworkDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'macOS asks once whether CopySync may connect to devices on your network. If you declined, turn on CopySync Daemon there.'**
+ String get macLocalNetworkDesc;
+
+ /// No description provided for @allowLan.
+ ///
+ /// In en, this message translates to:
+ /// **'Windows Firewall'**
+ String get allowLan;
+
+ /// No description provided for @allowLanDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Allow this when other devices can\'t reach this one, for example when pairing from another subnet. Asks for administrator approval once.'**
+ String get allowLanDesc;
+
+ /// No description provided for @allow.
+ ///
+ /// In en, this message translates to:
+ /// **'Allow'**
+ String get allow;
+
+ /// No description provided for @allowLanDone.
+ ///
+ /// In en, this message translates to:
+ /// **'Allowed. Other devices can now reach this one.'**
+ String get allowLanDone;
+
/// No description provided for @deviceName.
///
/// In en, this message translates to:
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
index 76dd067..1764b7f 100644
--- a/ui/lib/l10n/app_localizations_en.dart
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -24,7 +24,18 @@ class AppLocalizationsEn extends AppLocalizations {
String get linkServiceNotRunning => 'Service not running';
@override
- String get linkNoServer => 'No server connection';
+ String get linkLanMode => 'Looking for devices on this network';
+
+ @override
+ String get linkServerUnreachable =>
+ 'Can\'t reach the server; syncing on this network';
+
+ @override
+ String get linkNothingOn =>
+ 'Local network discovery is off and no server is set';
+
+ @override
+ String get linkLanBlocked => 'macOS is blocking the local network';
@override
String linkOnlinePeers(int count) {
@@ -376,11 +387,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get noDevicesBody =>
- 'Open CopySync on your other computer and link the two with a 6-character pairing code.';
-
- @override
- String get noDevicesNeedServer =>
- 'Connect to a signaling server in Settings before pairing.';
+ 'Open CopySync on your other computer and link the two with a 6-character pairing code. On the same network, nothing else is needed.';
@override
String get pairedDevices => 'Paired devices';
@@ -428,6 +435,30 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get unpaired => 'Unpaired';
+ @override
+ String get enterAddressEllipsis => 'Enter its address…';
+
+ @override
+ String setAddressTitle(String name) {
+ return 'Address of “$name”';
+ }
+
+ @override
+ String setAddressBody(String name) {
+ return 'Use this when the two devices are on different subnets, or both changed addresses. Enter the address shown on “$name” under Add device → Show a code.';
+ }
+
+ @override
+ String get addressSaved => 'Looking for it at that address';
+
+ @override
+ String get lanBlockedTitle => 'macOS is blocking the local network';
+
+ @override
+ String lanBlockedBody(String device) {
+ return 'Turn on CopySync Daemon in System Settings → Privacy & Security → Local Network. Until then, $device can\'t connect to devices on this network.';
+ }
+
@override
String get generateCode => 'Show a code';
@@ -454,6 +485,45 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get codeInvalid => 'A pairing code is 6 letters or digits';
+ @override
+ String get localAddress => 'Address';
+
+ @override
+ String get addressHint =>
+ 'On a different subnet? Enter this address on the other device as well.';
+
+ @override
+ String get addressCopied => 'Address copied';
+
+ @override
+ String get differentSubnet => 'On a different subnet?';
+
+ @override
+ String get peerAddress => 'Address shown under the code';
+
+ @override
+ String get pairNotFound =>
+ 'Couldn\'t find that device. If it\'s on a different subnet, enter the address shown under its code.';
+
+ @override
+ String get pairNotFoundAddress =>
+ 'Nothing answered at that address. Check the address and that the other device is still showing its code. A firewall on that device may also be blocking it.';
+
+ @override
+ String get codeWrong => 'That code isn\'t right, or it has expired';
+
+ @override
+ String get codeExpired =>
+ 'This code has expired. Show a new one on the other device.';
+
+ @override
+ String get addressInvalid =>
+ 'That address isn\'t valid. Enter something like 192.168.1.20.';
+
+ @override
+ String get pairNoChannel =>
+ 'Turn on local network discovery or set a server in Settings first.';
+
@override
String get enterCodeShown => 'Enter the code shown on your other device';
@@ -483,18 +553,18 @@ class AppLocalizationsEn extends AppLocalizations {
String get confirmMatch => 'They match, pair';
@override
- String get server => 'Server';
+ String get server => 'Server (optional)';
@override
String get serverFootnote =>
- 'The server only helps devices find each other and set up a direct connection. It can\'t see what they send.';
+ 'Only needed to sync between different networks, such as home and office. Devices on the same network connect without it. The server only helps devices find each other and can\'t see what they send.';
@override
String get signalingUrl => 'Signaling server';
@override
String get signalingUrlDesc =>
- 'Press Return to save; it reconnects right away';
+ 'Press Return to save. Leave it empty to sync on this network only.';
@override
String get signalingUrlPlaceholder => 'ws://server-address:8787/signal';
@@ -522,6 +592,49 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get notConnected => 'Not connected';
+ @override
+ String get notSet => 'Not set';
+
+ @override
+ String get notSetDesc => 'Syncing with devices on this network only';
+
+ @override
+ String get serverCleared => 'Server removed. Syncing on this network only.';
+
+ @override
+ String get localNetwork => 'Local network';
+
+ @override
+ String get lanFootnote =>
+ 'Uses UDP port 8788. If the devices are on different subnets, enter the other device\'s address when pairing.';
+
+ @override
+ String get lanDiscovery => 'Find devices on this network';
+
+ @override
+ String get lanDiscoveryDesc =>
+ 'Pair and sync without a server. Others on the network only see an anonymous entry that changes daily.';
+
+ @override
+ String get macLocalNetwork => 'Local Network access';
+
+ @override
+ String get macLocalNetworkDesc =>
+ 'macOS asks once whether CopySync may connect to devices on your network. If you declined, turn on CopySync Daemon there.';
+
+ @override
+ String get allowLan => 'Windows Firewall';
+
+ @override
+ String get allowLanDesc =>
+ 'Allow this when other devices can\'t reach this one, for example when pairing from another subnet. Asks for administrator approval once.';
+
+ @override
+ String get allow => 'Allow';
+
+ @override
+ String get allowLanDone => 'Allowed. Other devices can now reach this one.';
+
@override
String get deviceName => 'Device name';
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
index f52f879..2561e9e 100644
--- a/ui/lib/l10n/app_localizations_ja.dart
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -24,7 +24,16 @@ class AppLocalizationsJa extends AppLocalizations {
String get linkServiceNotRunning => 'サービス停止中';
@override
- String get linkNoServer => 'サーバーに未接続';
+ String get linkLanMode => 'このネットワークでデバイスを探しています';
+
+ @override
+ String get linkServerUnreachable => 'サーバーに接続できません。このネットワーク内では同期します';
+
+ @override
+ String get linkNothingOn => 'ローカルネットワークの検出がオフで、サーバーも未設定です';
+
+ @override
+ String get linkLanBlocked => 'macOS がローカルネットワークをブロックしています';
@override
String linkOnlinePeers(int count) {
@@ -316,10 +325,8 @@ class AppLocalizationsJa extends AppLocalizations {
String get noDevicesTitle => 'ペアリングしたデバイスはまだありません';
@override
- String get noDevicesBody => 'もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。';
-
- @override
- String get noDevicesNeedServer => 'ペアリングの前に、「設定」でシグナリングサーバーに接続してください。';
+ String get noDevicesBody =>
+ 'もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。同じネットワーク内なら、ほかに準備はいりません。';
@override
String get pairedDevices => 'ペアリング済みのデバイス';
@@ -367,6 +374,30 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get unpaired => 'ペアリングを解除しました';
+ @override
+ String get enterAddressEllipsis => 'アドレスを入力…';
+
+ @override
+ String setAddressTitle(String name) {
+ return '「$name」のアドレス';
+ }
+
+ @override
+ String setAddressBody(String name) {
+ return '2 台が別のサブネットにある場合や、どちらもアドレスが変わった場合に使います。「$name」の「デバイスを追加 → コードを表示」に表示されるアドレスを入力してください。';
+ }
+
+ @override
+ String get addressSaved => 'そのアドレスで探しています';
+
+ @override
+ String get lanBlockedTitle => 'macOS がローカルネットワークへのアクセスをブロックしています';
+
+ @override
+ String lanBlockedBody(String device) {
+ return '「システム設定 → プライバシーとセキュリティ → ローカルネットワーク」で CopySync Daemon をオンにしてください。オンにするまで、$deviceは同じネットワークのデバイスに接続できません。';
+ }
+
@override
String get generateCode => 'コードを表示';
@@ -393,6 +424,41 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get codeInvalid => 'ペアリングコードは 6 桁の英数字です';
+ @override
+ String get localAddress => 'アドレス';
+
+ @override
+ String get addressHint => '別のサブネットにある場合は、もう一台でこのアドレスも入力します';
+
+ @override
+ String get addressCopied => 'アドレスをコピーしました';
+
+ @override
+ String get differentSubnet => '別のサブネットにありますか?';
+
+ @override
+ String get peerAddress => 'コードの下に表示されたアドレス';
+
+ @override
+ String get pairNotFound =>
+ 'そのデバイスが見つかりません。別のサブネットにある場合は、コードの下に表示されたアドレスを入力してください。';
+
+ @override
+ String get pairNotFoundAddress =>
+ 'そのアドレスから応答がありません。アドレスと、相手がまだコードを表示しているかを確認してください。相手のファイアウォールがブロックしている可能性もあります。';
+
+ @override
+ String get codeWrong => 'コードが違うか、有効期限が切れています';
+
+ @override
+ String get codeExpired => 'このコードは無効になりました。もう一台で新しいコードを表示してください。';
+
+ @override
+ String get addressInvalid => 'アドレスの形式が正しくありません。192.168.1.20 のように入力してください。';
+
+ @override
+ String get pairNoChannel => '先に「設定」でローカルネットワークの検出をオンにするか、サーバーを設定してください。';
+
@override
String get enterCodeShown => 'もう一台のデバイスに表示されたコードを入力してください';
@@ -422,16 +488,17 @@ class AppLocalizationsJa extends AppLocalizations {
String get confirmMatch => '一致、ペアリング';
@override
- String get server => 'サーバー';
+ String get server => 'サーバー(任意)';
@override
- String get serverFootnote => 'サーバーはデバイス同士を見つけ、直接接続を取り持つだけです。やり取りする内容は見えません。';
+ String get serverFootnote =>
+ '家と会社のように、別々のネットワーク間で同期するときだけ必要です。同じネットワーク内のデバイスはサーバーなしで直接つながります。サーバーはデバイス同士を引き合わせるだけで、やり取りする内容は見えません。';
@override
String get signalingUrl => 'シグナリングサーバー';
@override
- String get signalingUrlDesc => 'Enter で保存し、すぐに再接続します';
+ String get signalingUrlDesc => 'Enter で保存。空欄にするとこのネットワーク内だけで同期します';
@override
String get signalingUrlPlaceholder => 'ws://サーバーアドレス:8787/signal';
@@ -458,6 +525,49 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get notConnected => '未接続';
+ @override
+ String get notSet => '未設定';
+
+ @override
+ String get notSetDesc => '同じネットワークのデバイスとだけ同期します';
+
+ @override
+ String get serverCleared => 'サーバーを削除しました。このネットワーク内だけで同期します';
+
+ @override
+ String get localNetwork => 'ローカルネットワーク';
+
+ @override
+ String get lanFootnote =>
+ 'UDP ポート 8788 を使います。2 台が別のサブネットにある場合は、ペアリング時に相手のアドレスを入力します。';
+
+ @override
+ String get lanDiscovery => 'このネットワークでデバイスを探す';
+
+ @override
+ String get lanDiscoveryDesc =>
+ 'サーバーなしでペアリングと同期ができます。ネットワーク上の他の人には、毎日変わる匿名の識別子しか見えません';
+
+ @override
+ String get macLocalNetwork => 'ローカルネットワークへのアクセス';
+
+ @override
+ String get macLocalNetworkDesc =>
+ 'CopySync がネットワーク上のデバイスに接続してよいか、macOS が一度だけ確認します。拒否した場合は、そこで CopySync Daemon をオンにしてください';
+
+ @override
+ String get allowLan => 'Windows ファイアウォール';
+
+ @override
+ String get allowLanDesc =>
+ '他のデバイスからこのデバイスに接続できないとき(別のサブネットからのペアリングなど)に許可します。管理者の承認を 1 回求めます';
+
+ @override
+ String get allow => '許可';
+
+ @override
+ String get allowLanDone => '許可しました。他のデバイスからこのデバイスに接続できます。';
+
@override
String get deviceName => 'デバイス名';
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
index 371a175..626b9bf 100644
--- a/ui/lib/l10n/app_localizations_zh.dart
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -24,7 +24,16 @@ class AppLocalizationsZh extends AppLocalizations {
String get linkServiceNotRunning => '后台服务未运行';
@override
- String get linkNoServer => '未连接服务器';
+ String get linkLanMode => '在局域网中查找设备';
+
+ @override
+ String get linkServerUnreachable => '连不上服务器,局域网内照常同步';
+
+ @override
+ String get linkNothingOn => '局域网发现已关闭,也没有设置服务器';
+
+ @override
+ String get linkLanBlocked => 'macOS 阻止了局域网访问';
@override
String linkOnlinePeers(int count) {
@@ -315,10 +324,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get noDevicesTitle => '还没有配对的设备';
@override
- String get noDevicesBody => '在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。';
-
- @override
- String get noDevicesNeedServer => '先在「设置」里连接信令服务器,才能配对设备。';
+ String get noDevicesBody =>
+ '在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。两台在同一个网络里时,不需要别的准备。';
@override
String get pairedDevices => '已配对的设备';
@@ -365,6 +372,30 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get unpaired => '已解除配对';
+ @override
+ String get enterAddressEllipsis => '输入它的地址…';
+
+ @override
+ String setAddressTitle(String name) {
+ return '「$name」的地址';
+ }
+
+ @override
+ String setAddressBody(String name) {
+ return '两台不在同一网段、或者都换了地址时用。输入「$name」上「添加设备 → 生成配对码」下面显示的地址。';
+ }
+
+ @override
+ String get addressSaved => '已记下,正在那个地址上找它';
+
+ @override
+ String get lanBlockedTitle => 'macOS 阻止了局域网访问';
+
+ @override
+ String lanBlockedBody(String device) {
+ return '在「系统设置 → 隐私与安全性 → 本地网络」里打开 CopySync Daemon。打开之前,$device连不上同一网络里的设备。';
+ }
+
@override
String get generateCode => '生成配对码';
@@ -391,6 +422,40 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get codeInvalid => '配对码是 6 位字母或数字';
+ @override
+ String get localAddress => '本机地址';
+
+ @override
+ String get addressHint => '不在同一网段时,另一台还要输入这个地址';
+
+ @override
+ String get addressCopied => '地址已拷贝';
+
+ @override
+ String get differentSubnet => '不在同一网段?';
+
+ @override
+ String get peerAddress => '对方配对码下面显示的地址';
+
+ @override
+ String get pairNotFound => '没找到那台设备。不在同一网段时,请输入它配对码下面显示的地址。';
+
+ @override
+ String get pairNotFoundAddress =>
+ '那个地址上没有回应。检查地址是否正确、对方是否还停在配对码页面;对方的防火墙也可能拦住了。';
+
+ @override
+ String get codeWrong => '配对码不对,或者已经失效';
+
+ @override
+ String get codeExpired => '配对码已失效,请在另一台上重新生成';
+
+ @override
+ String get addressInvalid => '地址格式不对,应当像 192.168.1.20 这样';
+
+ @override
+ String get pairNoChannel => '请先在「设置」里开启局域网发现,或者填写服务器地址。';
+
@override
String get enterCodeShown => '输入另一台设备上显示的配对码';
@@ -420,16 +485,17 @@ class AppLocalizationsZh extends AppLocalizations {
String get confirmMatch => '一致,确认配对';
@override
- String get server => '服务器';
+ String get server => '服务器(可选)';
@override
- String get serverFootnote => '服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。';
+ String get serverFootnote =>
+ '只在不同网络之间同步时需要,比如家里和公司;同一网络里的设备不用服务器也能直接连上。服务器只负责让设备找到彼此,看不到传输的内容。';
@override
String get signalingUrl => '信令服务器地址';
@override
- String get signalingUrlDesc => '按回车保存,保存后立即重新连接';
+ String get signalingUrlDesc => '按回车保存。留空表示只在局域网里同步';
@override
String get signalingUrlPlaceholder => 'ws://服务器地址:8787/signal';
@@ -455,6 +521,46 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get notConnected => '未连接';
+ @override
+ String get notSet => '未设置';
+
+ @override
+ String get notSetDesc => '只与同一网络里的设备同步';
+
+ @override
+ String get serverCleared => '已清除服务器地址,只在局域网里同步';
+
+ @override
+ String get localNetwork => '局域网';
+
+ @override
+ String get lanFootnote => '使用 UDP 端口 8788。两台不在同一网段时,配对时输入对方的地址。';
+
+ @override
+ String get lanDiscovery => '在局域网中查找设备';
+
+ @override
+ String get lanDiscoveryDesc => '不用服务器就能配对和同步。网络里的其他人只能看到一个每天都变的匿名标识';
+
+ @override
+ String get macLocalNetwork => '本地网络权限';
+
+ @override
+ String get macLocalNetworkDesc =>
+ 'macOS 会问一次是否允许 CopySync 连接网络里的设备。拒绝过的话,到那里打开 CopySync Daemon';
+
+ @override
+ String get allowLan => 'Windows 防火墙';
+
+ @override
+ String get allowLanDesc => '其他设备连不上这台时放行,比如从别的网段配对。会请求一次管理员权限';
+
+ @override
+ String get allow => '放行';
+
+ @override
+ String get allowLanDone => '已放行,其他设备现在可以连到这台了';
+
@override
String get deviceName => '设备名称';
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
index fe1b8fd..d87fc09 100644
--- a/ui/lib/l10n/app_zh.arb
+++ b/ui/lib/l10n/app_zh.arb
@@ -5,7 +5,10 @@
"navSettings": "设置",
"linkConnecting": "正在连接…",
"linkServiceNotRunning": "后台服务未运行",
- "linkNoServer": "未连接服务器",
+ "linkLanMode": "在局域网中查找设备",
+ "linkServerUnreachable": "连不上服务器,局域网内照常同步",
+ "linkNothingOn": "局域网发现已关闭,也没有设置服务器",
+ "linkLanBlocked": "macOS 阻止了局域网访问",
"linkOnlinePeers": "{count} 台设备在线",
"linkServerConnected": "已连接服务器",
"linkConnectionLost": "连接中断:{detail}",
@@ -89,8 +92,7 @@
"addDevice": "添加设备",
"thisDeviceFootnote": "配对时,{both}会显示同样的两行安全指纹:这台的和对方的。逐字核对一致才能确认。",
"noDevicesTitle": "还没有配对的设备",
- "noDevicesBody": "在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。",
- "noDevicesNeedServer": "先在「设置」里连接信令服务器,才能配对设备。",
+ "noDevicesBody": "在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。两台在同一个网络里时,不需要别的准备。",
"pairedDevices": "已配对的设备",
"pairedFootnote": "直连:数据在两台设备之间直接传输。中转:网络环境打不通直连时,经你的服务器转发,内容依然是端到端加密的。",
"offline": "离线",
@@ -105,6 +107,12 @@
"unpairBody": "两台设备将不再同步。以后想恢复,需要重新配对并核对指纹。",
"unpair": "解除配对",
"unpaired": "已解除配对",
+ "enterAddressEllipsis": "输入它的地址…",
+ "setAddressTitle": "「{name}」的地址",
+ "setAddressBody": "两台不在同一网段、或者都换了地址时用。输入「{name}」上「添加设备 → 生成配对码」下面显示的地址。",
+ "addressSaved": "已记下,正在那个地址上找它",
+ "lanBlockedTitle": "macOS 阻止了局域网访问",
+ "lanBlockedBody": "在「系统设置 → 隐私与安全性 → 本地网络」里打开 CopySync Daemon。打开之前,{device}连不上同一网络里的设备。",
"generateCode": "生成配对码",
"enterCode": "输入配对码",
"codeFailedTitle": "没能生成配对码",
@@ -113,6 +121,17 @@
"codeHint": "点击可拷贝,5 分钟内有效",
"afterEnterFootnote": "对方输入后,{both}会显示同样的两行安全指纹,核对一致再确认。",
"codeInvalid": "配对码是 6 位字母或数字",
+ "localAddress": "本机地址",
+ "addressHint": "不在同一网段时,另一台还要输入这个地址",
+ "addressCopied": "地址已拷贝",
+ "differentSubnet": "不在同一网段?",
+ "peerAddress": "对方配对码下面显示的地址",
+ "pairNotFound": "没找到那台设备。不在同一网段时,请输入它配对码下面显示的地址。",
+ "pairNotFoundAddress": "那个地址上没有回应。检查地址是否正确、对方是否还停在配对码页面;对方的防火墙也可能拦住了。",
+ "codeWrong": "配对码不对,或者已经失效",
+ "codeExpired": "配对码已失效,请在另一台上重新生成",
+ "addressInvalid": "地址格式不对,应当像 192.168.1.20 这样",
+ "pairNoChannel": "请先在「设置」里开启局域网发现,或者填写服务器地址。",
"enterCodeShown": "输入另一台设备上显示的配对码",
"pairingDone": "配对完成",
"pairingRejected": "已拒绝配对",
@@ -121,10 +140,10 @@
"verifyBody": "{both}上显示的这两行应当完全相同。有任何一个字符不同,说明连接可能被第三方篡改,请拒绝。",
"rejectMismatch": "不一致,拒绝",
"confirmMatch": "一致,确认配对",
- "server": "服务器",
- "serverFootnote": "服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。",
+ "server": "服务器(可选)",
+ "serverFootnote": "只在不同网络之间同步时需要,比如家里和公司;同一网络里的设备不用服务器也能直接连上。服务器只负责让设备找到彼此,看不到传输的内容。",
"signalingUrl": "信令服务器地址",
- "signalingUrlDesc": "按回车保存,保存后立即重新连接",
+ "signalingUrlDesc": "按回车保存。留空表示只在局域网里同步",
"signalingUrlPlaceholder": "ws://服务器地址:8787/signal",
"publicStun": "用公共服务器探测网络出口",
"publicStunDesc": "公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP",
@@ -133,6 +152,19 @@
"disconnectedDesc": "连不上服务器。检查地址是否正确、服务器是否在运行。",
"connected": "已连接",
"notConnected": "未连接",
+ "notSet": "未设置",
+ "notSetDesc": "只与同一网络里的设备同步",
+ "serverCleared": "已清除服务器地址,只在局域网里同步",
+ "localNetwork": "局域网",
+ "lanFootnote": "使用 UDP 端口 8788。两台不在同一网段时,配对时输入对方的地址。",
+ "lanDiscovery": "在局域网中查找设备",
+ "lanDiscoveryDesc": "不用服务器就能配对和同步。网络里的其他人只能看到一个每天都变的匿名标识",
+ "macLocalNetwork": "本地网络权限",
+ "macLocalNetworkDesc": "macOS 会问一次是否允许 CopySync 连接网络里的设备。拒绝过的话,到那里打开 CopySync Daemon",
+ "allowLan": "Windows 防火墙",
+ "allowLanDesc": "其他设备连不上这台时放行,比如从别的网段配对。会请求一次管理员权限",
+ "allow": "放行",
+ "allowLanDone": "已放行,其他设备现在可以连到这台了",
"deviceName": "设备名称",
"deviceNameDesc": "显示在其他设备的列表里",
"language": "语言",
diff --git a/ui/lib/main.dart b/ui/lib/main.dart
index f8c3cca..f1abfd8 100644
--- a/ui/lib/main.dart
+++ b/ui/lib/main.dart
@@ -286,12 +286,17 @@ class _ConnectionFooter extends StatelessWidget {
final online = state.onlinePeerCount;
final l = context.l10n;
+ // 服务器是可选的:没填地址时只在局域网里同步,是正常状态,不用警示色
final (color, label) = switch (state.link) {
LinkState.connecting => (p.textFaint, l.linkConnecting),
LinkState.offline => (p.danger, state.error ?? l.linkServiceNotRunning),
- LinkState.online when !signaling => (p.warning, l.linkNoServer),
+ LinkState.online when state.lanBlocked => (p.warning, l.linkLanBlocked),
LinkState.online when online > 0 => (p.online, l.linkOnlinePeers(online)),
- LinkState.online => (p.online, l.linkServerConnected),
+ LinkState.online when state.serverConfigured && !signaling =>
+ (p.warning, state.lanEnabled ? l.linkServerUnreachable : l.notConnected),
+ LinkState.online when state.serverConfigured => (p.online, l.linkServerConnected),
+ LinkState.online when state.lanEnabled => (p.textFaint, l.linkLanMode),
+ LinkState.online => (p.warning, l.linkNothingOn),
};
return Container(
diff --git a/ui/lib/pages/devices_page.dart b/ui/lib/pages/devices_page.dart
index f1e94c8..0566097 100644
--- a/ui/lib/pages/devices_page.dart
+++ b/ui/lib/pages/devices_page.dart
@@ -17,7 +17,8 @@ class DevicesPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final state = AppScope.of(context);
- final canPair = state.isOnline && (state.status?.signalingConnected ?? false);
+ // 同一网络里不需要服务器,后台服务在运行就能配对;连不上对方时由配对框给出原因
+ final canPair = state.isOnline;
final l = context.l10n;
return Column(
@@ -36,6 +37,11 @@ class DevicesPage extends StatelessWidget {
),
],
),
+ if (state.lanBlocked)
+ const Padding(
+ padding: EdgeInsets.fromLTRB(Insets.xl, 0, Insets.xl, Insets.md),
+ child: LanBlockedNotice(),
+ ),
Expanded(
child: ListView(
padding: const EdgeInsets.fromLTRB(Insets.xl, 0, Insets.xl, Insets.xl),
@@ -52,7 +58,7 @@ class DevicesPage extends StatelessWidget {
child: EmptyState(
icon: AppIcons.deviceLaptop,
title: l.noDevicesTitle,
- description: canPair ? l.noDevicesBody : l.noDevicesNeedServer,
+ description: l.noDevicesBody,
action: canPair
? FilledButton(
onPressed: () => _startPairing(context),
@@ -153,13 +159,20 @@ class _DeviceMenu extends StatelessWidget {
position: PopupMenuPosition.under,
itemBuilder: (ctx) => [
PopupMenuItem(value: 'copy', height: 34, child: Text(l.copyFingerprint)),
+ // 局域网里找不到对方时(跨网段、两边都换了地址),手动告诉后台服务去哪里找
+ if (!device.online)
+ PopupMenuItem(value: 'address', height: 34, child: Text(l.enterAddressEllipsis)),
PopupMenuItem(
value: 'unpair',
height: 34,
child: Text(l.unpairEllipsis, style: TextStyle(color: ctx.palette.danger)),
),
],
- onSelected: (v) => v == 'copy' ? _copy(context) : _unpair(context),
+ onSelected: (v) => switch (v) {
+ 'copy' => _copy(context),
+ 'address' => _setAddress(context),
+ _ => _unpair(context),
+ },
child: IgnorePointer(
child: IconAction(icon: AppIcons.ellipsis, tooltip: ''),
),
@@ -171,6 +184,58 @@ class _DeviceMenu extends StatelessWidget {
if (context.mounted) showToast(context, context.l10n.fingerprintCopied);
}
+ Future<void> _setAddress(BuildContext context) async {
+ final state = AppScope.read(context);
+ final l = context.l10n;
+ final controller = TextEditingController();
+ final address = await showDialog<String>(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text(l.setAddressTitle(device.name)),
+ content: SizedBox(
+ width: 360,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(l.setAddressBody(device.name)),
+ const SizedBox(height: Insets.lg),
+ TextField(
+ controller: controller,
+ autofocus: true,
+ style: const TextStyle(fontFamily: monoFamily, fontSize: 14),
+ decoration: const InputDecoration(hintText: '192.168.1.20'),
+ onSubmitted: (v) => Navigator.pop(ctx, v),
+ ),
+ ],
+ ),
+ ),
+ actions: [
+ OutlinedButton(onPressed: () => Navigator.pop(ctx), child: Text(l.cancel)),
+ FilledButton(onPressed: () => Navigator.pop(ctx, controller.text), child: Text(l.save)),
+ ],
+ ),
+ );
+ controller.dispose();
+ if (address == null || address.trim().isEmpty) return;
+ try {
+ await state.setDeviceAddress(device.id, address);
+ if (context.mounted) showToast(context, l.addressSaved);
+ } catch (e) {
+ if (!context.mounted) return;
+ final failure = AppState.pairingFailure(e);
+ showToast(
+ context,
+ switch (failure) {
+ PairingFailure.badAddress => l.addressInvalid,
+ PairingFailure.noChannel => l.pairNoChannel,
+ _ => AppState.describeError(e),
+ },
+ error: true,
+ );
+ }
+ }
+
Future<void> _unpair(BuildContext context) async {
final state = AppScope.read(context);
final l = context.l10n;
@@ -198,3 +263,27 @@ class _DeviceMenu extends StatelessWidget {
}
}
}
+
+/// macOS 拦下了发往局域网的包。不放行的话,同一网络里的设备连不上这台。
+class LanBlockedNotice extends StatelessWidget {
+ const LanBlockedNotice({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final l = context.l10n;
+ return Notice(
+ title: l.lanBlockedTitle,
+ message: l.lanBlockedBody(Wording.thisDeviceInText),
+ action: OutlinedButton(
+ onPressed: () async {
+ try {
+ await AppScope.read(context).requestLocalNetworkPermission();
+ } catch (e) {
+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ },
+ child: Text(l.openSystemSettings),
+ ),
+ );
+ }
+}
diff --git a/ui/lib/pages/settings_page.dart b/ui/lib/pages/settings_page.dart
index 77b9b1a..5424447 100644
--- a/ui/lib/pages/settings_page.dart
+++ b/ui/lib/pages/settings_page.dart
@@ -1,4 +1,6 @@
+import 'dart:io';
+
import 'package:fixnum/fixnum.dart';
import 'package:flutter/material.dart';
@@ -59,6 +61,12 @@ class _SettingsPageState extends State<SettingsPage> {
final p = context.palette;
final l = context.l10n;
final connected = state.status?.signalingConnected == true;
+ // 服务器是可选的:没填地址不是故障,用中性色
+ final (Color statusColor, String statusLabel, String statusDesc) = switch ((state.serverConfigured, connected)) {
+ (false, _) => (p.textFaint, l.notSet, l.notSetDesc),
+ (true, true) => (p.online, l.connected, l.connectedDesc),
+ (true, false) => (p.danger, l.notConnected, l.disconnectedDesc),
+ };
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -105,12 +113,41 @@ class _SettingsPageState extends State<SettingsPage> {
),
SettingRow(
title: l.connectionStatus,
- description: connected ? l.connectedDesc : l.disconnectedDesc,
- child: StatusDot(
- color: connected ? p.online : p.danger,
- label: connected ? l.connected : l.notConnected,
+ description: statusDesc,
+ child: StatusDot(color: statusColor, label: statusLabel),
+ ),
+ ]),
+ ),
+ GroupSection(
+ title: l.localNetwork,
+ footnote: l.lanFootnote,
+ child: GroupBox(children: [
+ SettingRow(
+ title: l.lanDiscovery,
+ description: l.lanDiscoveryDesc,
+ child: SmallSwitch(
+ value: !cfg.lanDisabled,
+ onChanged: (v) => _update(state, cfg..lanDisabled = !v),
),
),
+ if (Platform.isMacOS)
+ SettingRow(
+ title: l.macLocalNetwork,
+ description: l.macLocalNetworkDesc,
+ child: OutlinedButton(
+ onPressed: () => _allowLocalNetwork(state, null),
+ child: Text(l.openSystemSettings),
+ ),
+ ),
+ if (Platform.isWindows)
+ SettingRow(
+ title: l.allowLan,
+ description: l.allowLanDesc,
+ child: OutlinedButton(
+ onPressed: () => _allowLocalNetwork(state, l.allowLanDone),
+ child: Text(l.allow),
+ ),
+ ),
]),
),
GroupSection(
@@ -310,14 +347,26 @@ class _SettingsPageState extends State<SettingsPage> {
}
Future<void> _saveServer(AppState state, Config cfg) async {
+ final l = context.l10n;
final url = _serverController.text.trim();
- if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
- showToast(context, context.l10n.urlMustBeWs, error: true);
+ // 留空就是不用服务器,只在局域网里同步
+ if (url.isNotEmpty && !url.startsWith('ws://') && !url.startsWith('wss://')) {
+ showToast(context, l.urlMustBeWs, error: true);
return;
}
setState(() => _serverDirty = false);
_lastLoadedServer = url;
- await _update(state, cfg..signalingUrl = url, message: context.l10n.serverUpdated);
+ await _update(state, cfg..signalingUrl = url, message: url.isEmpty ? l.serverCleared : l.serverUpdated);
+ }
+
+ /// macOS 打开「本地网络」设置面板;Windows 弹出 UAC,在防火墙里放行后台服务。
+ Future<void> _allowLocalNetwork(AppState state, String? doneMessage) async {
+ try {
+ await state.requestLocalNetworkPermission();
+ if (mounted && doneMessage != null) showToast(context, doneMessage);
+ } catch (e) {
+ if (mounted) showToast(context, AppState.describeError(e), error: true);
+ }
}
Future<void> _saveName(AppState state, Config cfg) async {
diff --git a/ui/lib/widgets/pairing_dialog.dart b/ui/lib/widgets/pairing_dialog.dart
index c57471c..992a135 100644
--- a/ui/lib/widgets/pairing_dialog.dart
+++ b/ui/lib/widgets/pairing_dialog.dart
@@ -71,7 +71,7 @@ class _PairingDialogState extends State<PairingDialog> {
onChanged: (t) => setState(() => _tab = t),
),
SizedBox(
- height: 272,
+ height: 312,
// IndexedStack 让两页都常驻:来回切换不会重新生成配对码
child: IndexedStack(
index: _tab,
@@ -94,6 +94,7 @@ class _GenerateTab extends StatefulWidget {
class _GenerateTabState extends State<_GenerateTab> {
String? _code;
+ List<String> _addresses = const [];
String? _error;
bool _loading = false;
@@ -109,10 +110,19 @@ class _GenerateTabState extends State<_GenerateTab> {
_error = null;
});
try {
- final code = await AppScope.read(context).createPairingCode();
- if (mounted) setState(() => _code = code);
+ final got = await AppScope.read(context).createPairingCode();
+ if (mounted) {
+ setState(() {
+ _code = got.code;
+ _addresses = got.addresses;
+ });
+ }
} catch (e) {
- if (mounted) setState(() => _error = AppState.describeError(e));
+ if (!mounted) return;
+ final l = context.l10n;
+ setState(() => _error = AppState.pairingFailure(e) == PairingFailure.noChannel
+ ? l.pairNoChannel
+ : AppState.describeError(e));
} finally {
if (mounted) setState(() => _loading = false);
}
@@ -175,6 +185,11 @@ class _GenerateTabState extends State<_GenerateTab> {
),
const SizedBox(height: Insets.sm),
Text(l.codeHint, style: context.text.labelSmall),
+ if (_addresses.isNotEmpty) ...[
+ const SizedBox(height: Insets.lg),
+ _AddressLine(addresses: _addresses),
+ ],
+ const SizedBox(height: Insets.lg),
const Spacer(),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -196,6 +211,44 @@ class _GenerateTabState extends State<_GenerateTab> {
}
}
+/// 配对码下面的本机地址。同一网段时用不上;跨网段时对方要连同配对码一起输入。
+class _AddressLine extends StatelessWidget {
+ const _AddressLine({required this.addresses});
+
+ final List<String> addresses;
+
+ @override
+ Widget build(BuildContext context) {
+ final p = context.palette;
+ final l = context.l10n;
+ return Column(
+ children: [
+ MouseRegion(
+ cursor: SystemMouseCursors.click,
+ child: GestureDetector(
+ onTap: () async {
+ await Clipboard.setData(ClipboardData(text: addresses.first));
+ if (context.mounted) showToast(context, l.addressCopied);
+ },
+ child: Text.rich(
+ TextSpan(children: [
+ TextSpan(text: '${l.localAddress} ', style: context.text.bodySmall),
+ TextSpan(
+ text: addresses.join(' · '),
+ style: TextStyle(fontFamily: monoFamily, fontSize: 13, color: p.text),
+ ),
+ ]),
+ textAlign: TextAlign.center,
+ ),
+ ),
+ ),
+ const SizedBox(height: 2),
+ Text(l.addressHint, style: context.text.labelSmall, textAlign: TextAlign.center),
+ ],
+ );
+ }
+}
+
class _JoinTab extends StatefulWidget {
const _JoinTab();
@@ -205,22 +258,28 @@ class _JoinTab extends StatefulWidget {
class _JoinTabState extends State<_JoinTab> {
final _controller = TextEditingController();
+ final _addressController = TextEditingController();
bool _busy = false;
+ // 地址框默认收起:同一网段时用不上,找不到对方时再自动展开
+ bool _showAddress = false;
String? _error;
@override
void dispose() {
_controller.dispose();
+ _addressController.dispose();
super.dispose();
}
Future<void> _submit() async {
if (_busy) return;
+ final l = context.l10n;
final code = _controller.text.trim();
if (code.length != 6) {
- setState(() => _error = context.l10n.codeInvalid);
+ setState(() => _error = l.codeInvalid);
return;
}
+ final address = _showAddress ? _addressController.text.trim() : '';
setState(() {
_busy = true;
_error = null;
@@ -228,9 +287,21 @@ class _JoinTabState extends State<_JoinTab> {
try {
// Shell 统一响应 pendingPairing,生成方和输入方都只有一个确认入口。
// 事件可能先于 RPC 返回,因此这里也不能 pop 最上层路由。
- await AppScope.read(context).redeemPairingCode(code);
+ await AppScope.read(context).redeemPairingCode(code, address: address);
} catch (e) {
- if (mounted) setState(() => _error = AppState.describeError(e));
+ if (!mounted) return;
+ final failure = AppState.pairingFailure(e);
+ setState(() {
+ if (failure == PairingFailure.notFound) _showAddress = true;
+ _error = switch (failure) {
+ PairingFailure.notFound => address.isEmpty ? l.pairNotFound : l.pairNotFoundAddress,
+ PairingFailure.wrongCode => l.codeWrong,
+ PairingFailure.codeExpired => l.codeExpired,
+ PairingFailure.badAddress => l.addressInvalid,
+ PairingFailure.noChannel => l.pairNoChannel,
+ PairingFailure.other => AppState.describeError(e),
+ };
+ });
} finally {
if (mounted) setState(() => _busy = false);
}
@@ -274,6 +345,26 @@ class _JoinTabState extends State<_JoinTab> {
),
onSubmitted: (_) => _submit(),
),
+ const SizedBox(height: Insets.sm),
+ if (_showAddress)
+ TextField(
+ controller: _addressController,
+ textAlign: TextAlign.center,
+ style: const TextStyle(fontFamily: monoFamily, fontSize: 14),
+ decoration: InputDecoration(
+ labelText: l.peerAddress,
+ hintText: '192.168.1.20',
+ hintStyle: TextStyle(color: p.textFaint),
+ ),
+ onSubmitted: (_) => _submit(),
+ )
+ else
+ Center(
+ child: TextButton(
+ onPressed: () => setState(() => _showAddress = true),
+ child: Text(l.differentSubnet),
+ ),
+ ),
if (_error != null) ...[
const SizedBox(height: Insets.sm),
Text(
@@ -282,6 +373,7 @@ class _JoinTabState extends State<_JoinTab> {
textAlign: TextAlign.center,
),
],
+ const SizedBox(height: Insets.lg),
const Spacer(),
FilledButton(
onPressed: _busy ? null : _submit,
diff --git a/ui/test/i18n_test.dart b/ui/test/i18n_test.dart
index 4a44ad6..69a88fd 100644
--- a/ui/test/i18n_test.dart
+++ b/ui/test/i18n_test.dart
@@ -11,7 +11,7 @@ import 'package:copysync_ui/widgets/pairing_dialog.dart';
class _DemoState extends AppState {
@override
- Future<String> createPairingCode() async => 'K7MP2X';
+ Future<PairingCode> createPairingCode() async => (code: 'K7MP2X', addresses: ['192.168.1.20']);
}
AppState _demo(String language, {LinkState link = LinkState.online, ServiceState? service}) =>
diff --git a/ui/test/pairing_flow_test.dart b/ui/test/pairing_flow_test.dart
index 55e1752..af33aca 100644
--- a/ui/test/pairing_flow_test.dart
+++ b/ui/test/pairing_flow_test.dart
@@ -6,6 +6,7 @@ import 'package:copysync_ui/main.dart';
import 'package:copysync_ui/widgets/pairing_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
+import 'package:grpc/grpc.dart';
Device pendingPeer([String session = 'session-1']) => Device(
id: 'peer',
@@ -17,11 +18,14 @@ Device pendingPeer([String session = 'session-1']) => Device(
class PairingState extends AppState {
final redemption = Completer<Device>();
final confirmations = <(String, bool)>[];
+ final redeemedWith = <(String, String)>[];
+ Object? nextRedeemFailure;
bool failConfirmation = false;
+ // 没有服务器、只开着局域网:这是新装的默认状态,照样能配对
PairingState() {
debugSeed(
- status: Status(signalingConnected: true),
+ status: Status(lanEnabled: true),
config: Config(),
self: Device(
id: 'self',
@@ -34,10 +38,16 @@ class PairingState extends AppState {
void receive(Device peer) => debugEvent(Event(deviceChanged: peer));
@override
- Future<String> createPairingCode() async => 'ABC123';
+ Future<PairingCode> createPairingCode() async => (code: 'ABC123', addresses: ['192.168.1.20']);
@override
- Future<Device> redeemPairingCode(String code) async {
+ Future<Device> redeemPairingCode(String code, {String address = ''}) async {
+ redeemedWith.add((code, address));
+ final failure = nextRedeemFailure;
+ if (failure != null) {
+ nextRedeemFailure = null;
+ throw failure;
+ }
final peer = await redemption.future;
receive(peer);
return peer;
@@ -160,4 +170,79 @@ void main() {
state.receive(pendingPeer());
expect(state.pendingPairing?.pairingSession, 'session-2');
});
+
+ testWidgets('生成配对码时显示本机地址,跨网段时对方要输入它', (tester) async {
+ final state = PairingState();
+ addTearDown(state.dispose);
+ await openSetup(tester, state);
+ expect(find.text('ABC123'), findsOneWidget);
+ expect(find.textContaining('192.168.1.20', findRichText: true), findsOneWidget);
+ expect(find.text('不在同一网段时,另一台还要输入这个地址'), findsOneWidget);
+ });
+
+ testWidgets('局域网里找不到对方时展开地址框,带上地址重试', (tester) async {
+ final state = PairingState()
+ ..nextRedeemFailure = GrpcError.notFound('not_found: 没在局域网里找到正在配对的设备');
+ addTearDown(state.dispose);
+ await openSetup(tester, state);
+ await tester.tap(find.text('输入配对码'));
+ await tester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'abc123');
+ await tester.tap(find.text('继续'));
+ await tester.pumpAndSettle();
+
+ expect(find.text('没找到那台设备。不在同一网段时,请输入它配对码下面显示的地址。'), findsOneWidget);
+ final fields = find.byType(TextField);
+ expect(fields, findsNWidgets(2));
+ await tester.enterText(fields.last, '192.168.1.20');
+ await tester.tap(find.text('继续'));
+ state.redemption.complete(pendingPeer());
+ await tester.pumpAndSettle();
+
+ expect(state.redeemedWith, [('ABC123', ''), ('ABC123', '192.168.1.20')]);
+ expectSingleConfirmation();
+ });
+
+ testWidgets('配对码不对时给出本地化的原因', (tester) async {
+ final state = PairingState()
+ ..nextRedeemFailure = GrpcError.invalidArgument('wrong_code: 配对码不对');
+ addTearDown(state.dispose);
+ await openSetup(tester, state);
+ await tester.tap(find.text('输入配对码'));
+ await tester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'ABC123');
+ await tester.tap(find.text('继续'));
+ await tester.pumpAndSettle();
+ expect(find.text('配对码不对,或者已经失效'), findsOneWidget);
+ // 不是「找不到」,地址框保持收起
+ expect(find.byType(TextField), findsOneWidget);
+ });
+
+ group('侧边栏的连接状态', () {
+ Future<void> pumpWith(WidgetTester tester, Status status) async {
+ final state = PairingState();
+ addTearDown(state.dispose);
+ state.debugSeed(status: status, config: Config(), self: Device(id: 'self', name: '本机'));
+ await tester.pumpWidget(CopySyncApp(state: state));
+ await tester.pumpAndSettle();
+ }
+
+ testWidgets('没设置服务器时是局域网模式,不算异常', (tester) async {
+ await pumpWith(tester, Status(lanEnabled: true));
+ expect(find.text('在局域网中查找设备'), findsOneWidget);
+ });
+
+ testWidgets('设置了服务器但连不上时提示仍在局域网里同步', (tester) async {
+ await pumpWith(tester, Status(lanEnabled: true, serverConfigured: true));
+ expect(find.text('连不上服务器,局域网内照常同步'), findsOneWidget);
+ });
+
+ testWidgets('macOS 拦下局域网时在设备页给出处理办法', (tester) async {
+ await pumpWith(tester, Status(lanEnabled: true, lanBlocked: true));
+ await tester.tap(find.text('设备').first);
+ await tester.pumpAndSettle();
+ expect(find.text('macOS 阻止了局域网访问'), findsWidgets);
+ expect(find.text('打开系统设置'), findsOneWidget);
+ });
+ });
}
diff --git a/ui/tool/l10n/strings.py b/ui/tool/l10n/strings.py
index ef95e04..dc29d45 100644
--- a/ui/tool/l10n/strings.py
+++ b/ui/tool/l10n/strings.py
@@ -19,7 +19,10 @@ S = [
("navSettings", "Settings", "设置", "設定"),
("linkConnecting", "Connecting…", "正在连接…", "接続中…"),
("linkServiceNotRunning", "Service not running", "后台服务未运行", "サービス停止中"),
- ("linkNoServer", "No server connection", "未连接服务器", "サーバーに未接続"),
+ ("linkLanMode", "Looking for devices on this network", "在局域网中查找设备", "このネットワークでデバイスを探しています"),
+ ("linkServerUnreachable", "Can't reach the server; syncing on this network", "连不上服务器,局域网内照常同步", "サーバーに接続できません。このネットワーク内では同期します"),
+ ("linkNothingOn", "Local network discovery is off and no server is set", "局域网发现已关闭,也没有设置服务器", "ローカルネットワークの検出がオフで、サーバーも未設定です"),
+ ("linkLanBlocked", "macOS is blocking the local network", "macOS 阻止了局域网访问", "macOS がローカルネットワークをブロックしています"),
("linkOnlinePeers", "{count, plural, =1{1 device online} other{{count} devices online}}", "{count} 台设备在线", "{count} 台がオンライン"),
("linkServerConnected", "Connected to the server", "已连接服务器", "サーバーに接続済み"),
("linkConnectionLost", "Connection lost: {detail}", "连接中断:{detail}", "接続が切れました:{detail}"),
@@ -116,8 +119,7 @@ S = [
("addDevice", "Add device", "添加设备", "デバイスを追加"),
("thisDeviceFootnote", "When pairing, {both} show the same two lines of security fingerprints, one for each device. Confirm only if they match character for character.", "配对时,{both}会显示同样的两行安全指纹:这台的和对方的。逐字核对一致才能确认。", "ペアリング時、{both}に同じ 2 行のセキュリティ指紋(このデバイスと相手のもの)が表示されます。1 文字ずつ一致を確かめてから確定してください。"),
("noDevicesTitle", "No paired devices yet", "还没有配对的设备", "ペアリングしたデバイスはまだありません"),
- ("noDevicesBody", "Open CopySync on your other computer and link the two with a 6-character pairing code.", "在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。", "もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。"),
- ("noDevicesNeedServer", "Connect to a signaling server in Settings before pairing.", "先在「设置」里连接信令服务器,才能配对设备。", "ペアリングの前に、「設定」でシグナリングサーバーに接続してください。"),
+ ("noDevicesBody", "Open CopySync on your other computer and link the two with a 6-character pairing code. On the same network, nothing else is needed.", "在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。两台在同一个网络里时,不需要别的准备。", "もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。同じネットワーク内なら、ほかに準備はいりません。"),
("pairedDevices", "Paired devices", "已配对的设备", "ペアリング済みのデバイス"),
("pairedFootnote", "Direct: data goes straight between the two devices. Relay: when the network blocks a direct path, data goes through your server and stays end-to-end encrypted.", "直连:数据在两台设备之间直接传输。中转:网络环境打不通直连时,经你的服务器转发,内容依然是端到端加密的。", "直接接続:データは 2 台のデバイス間で直接やり取りされます。中継:直接つながらないネットワークでは、あなたのサーバーを経由します。内容はエンドツーエンドで暗号化されたままです。"),
("offline", "Offline", "离线", "オフライン"),
@@ -132,6 +134,12 @@ S = [
("unpairBody", "The two devices will stop syncing. To sync again, you'll need to pair them and check the fingerprints again.", "两台设备将不再同步。以后想恢复,需要重新配对并核对指纹。", "2 台のデバイスは同期しなくなります。再開するには、もう一度ペアリングして指紋を確かめる必要があります。"),
("unpair", "Unpair", "解除配对", "ペアリングを解除"),
("unpaired", "Unpaired", "已解除配对", "ペアリングを解除しました"),
+ ("enterAddressEllipsis", "Enter its address…", "输入它的地址…", "アドレスを入力…"),
+ ("setAddressTitle", "Address of “{name}”", "「{name}」的地址", "「{name}」のアドレス"),
+ ("setAddressBody", "Use this when the two devices are on different subnets, or both changed addresses. Enter the address shown on “{name}” under Add device → Show a code.", "两台不在同一网段、或者都换了地址时用。输入「{name}」上「添加设备 → 生成配对码」下面显示的地址。", "2 台が別のサブネットにある場合や、どちらもアドレスが変わった場合に使います。「{name}」の「デバイスを追加 → コードを表示」に表示されるアドレスを入力してください。"),
+ ("addressSaved", "Looking for it at that address", "已记下,正在那个地址上找它", "そのアドレスで探しています"),
+ ("lanBlockedTitle", "macOS is blocking the local network", "macOS 阻止了局域网访问", "macOS がローカルネットワークへのアクセスをブロックしています"),
+ ("lanBlockedBody", "Turn on CopySync Daemon in System Settings → Privacy & Security → Local Network. Until then, {device} can't connect to devices on this network.", "在「系统设置 → 隐私与安全性 → 本地网络」里打开 CopySync Daemon。打开之前,{device}连不上同一网络里的设备。", "「システム設定 → プライバシーとセキュリティ → ローカルネットワーク」で CopySync Daemon をオンにしてください。オンにするまで、{device}は同じネットワークのデバイスに接続できません。"),
# ── 配对 ──
("generateCode", "Show a code", "生成配对码", "コードを表示"),
@@ -142,6 +150,17 @@ S = [
("codeHint", "Click to copy. Valid for 5 minutes.", "点击可拷贝,5 分钟内有效", "クリックでコピー。有効期間は 5 分です。"),
("afterEnterFootnote", "Once it's entered, {both} show the same two lines of security fingerprints. Confirm only if they match.", "对方输入后,{both}会显示同样的两行安全指纹,核对一致再确认。", "入力されると、{both}に同じ 2 行のセキュリティ指紋が表示されます。一致を確かめてから確定してください。"),
("codeInvalid", "A pairing code is 6 letters or digits", "配对码是 6 位字母或数字", "ペアリングコードは 6 桁の英数字です"),
+ ("localAddress", "Address", "本机地址", "アドレス"),
+ ("addressHint", "On a different subnet? Enter this address on the other device as well.", "不在同一网段时,另一台还要输入这个地址", "別のサブネットにある場合は、もう一台でこのアドレスも入力します"),
+ ("addressCopied", "Address copied", "地址已拷贝", "アドレスをコピーしました"),
+ ("differentSubnet", "On a different subnet?", "不在同一网段?", "別のサブネットにありますか?"),
+ ("peerAddress", "Address shown under the code", "对方配对码下面显示的地址", "コードの下に表示されたアドレス"),
+ ("pairNotFound", "Couldn't find that device. If it's on a different subnet, enter the address shown under its code.", "没找到那台设备。不在同一网段时,请输入它配对码下面显示的地址。", "そのデバイスが見つかりません。別のサブネットにある場合は、コードの下に表示されたアドレスを入力してください。"),
+ ("pairNotFoundAddress", "Nothing answered at that address. Check the address and that the other device is still showing its code. A firewall on that device may also be blocking it.", "那个地址上没有回应。检查地址是否正确、对方是否还停在配对码页面;对方的防火墙也可能拦住了。", "そのアドレスから応答がありません。アドレスと、相手がまだコードを表示しているかを確認してください。相手のファイアウォールがブロックしている可能性もあります。"),
+ ("codeWrong", "That code isn't right, or it has expired", "配对码不对,或者已经失效", "コードが違うか、有効期限が切れています"),
+ ("codeExpired", "This code has expired. Show a new one on the other device.", "配对码已失效,请在另一台上重新生成", "このコードは無効になりました。もう一台で新しいコードを表示してください。"),
+ ("addressInvalid", "That address isn't valid. Enter something like 192.168.1.20.", "地址格式不对,应当像 192.168.1.20 这样", "アドレスの形式が正しくありません。192.168.1.20 のように入力してください。"),
+ ("pairNoChannel", "Turn on local network discovery or set a server in Settings first.", "请先在「设置」里开启局域网发现,或者填写服务器地址。", "先に「設定」でローカルネットワークの検出をオンにするか、サーバーを設定してください。"),
("enterCodeShown", "Enter the code shown on your other device", "输入另一台设备上显示的配对码", "もう一台のデバイスに表示されたコードを入力してください"),
("pairingDone", "Paired", "配对完成", "ペアリングしました"),
("pairingRejected", "Pairing declined", "已拒绝配对", "ペアリングを拒否しました"),
@@ -152,10 +171,10 @@ S = [
("confirmMatch", "They match, pair", "一致,确认配对", "一致、ペアリング"),
# ── 设置 ──
- ("server", "Server", "服务器", "サーバー"),
- ("serverFootnote", "The server only helps devices find each other and set up a direct connection. It can't see what they send.", "服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。", "サーバーはデバイス同士を見つけ、直接接続を取り持つだけです。やり取りする内容は見えません。"),
+ ("server", "Server (optional)", "服务器(可选)", "サーバー(任意)"),
+ ("serverFootnote", "Only needed to sync between different networks, such as home and office. Devices on the same network connect without it. The server only helps devices find each other and can't see what they send.", "只在不同网络之间同步时需要,比如家里和公司;同一网络里的设备不用服务器也能直接连上。服务器只负责让设备找到彼此,看不到传输的内容。", "家と会社のように、別々のネットワーク間で同期するときだけ必要です。同じネットワーク内のデバイスはサーバーなしで直接つながります。サーバーはデバイス同士を引き合わせるだけで、やり取りする内容は見えません。"),
("signalingUrl", "Signaling server", "信令服务器地址", "シグナリングサーバー"),
- ("signalingUrlDesc", "Press Return to save; it reconnects right away", "按回车保存,保存后立即重新连接", "Enter で保存し、すぐに再接続します"),
+ ("signalingUrlDesc", "Press Return to save. Leave it empty to sync on this network only.", "按回车保存。留空表示只在局域网里同步", "Enter で保存。空欄にするとこのネットワーク内だけで同期します"),
("signalingUrlPlaceholder", "ws://server-address:8787/signal", "ws://服务器地址:8787/signal", "ws://サーバーアドレス:8787/signal"),
("publicStun", "Probe with public servers", "用公共服务器探测网络出口", "公開サーバーで出口を調べる"),
("publicStunDesc", "On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.", "公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP", "複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。"),
@@ -164,6 +183,19 @@ S = [
("disconnectedDesc", "Can't reach the server. Check the address and that the server is running.", "连不上服务器。检查地址是否正确、服务器是否在运行。", "サーバーに接続できません。アドレスとサーバーの稼働を確認してください。"),
("connected", "Connected", "已连接", "接続済み"),
("notConnected", "Not connected", "未连接", "未接続"),
+ ("notSet", "Not set", "未设置", "未設定"),
+ ("notSetDesc", "Syncing with devices on this network only", "只与同一网络里的设备同步", "同じネットワークのデバイスとだけ同期します"),
+ ("serverCleared", "Server removed. Syncing on this network only.", "已清除服务器地址,只在局域网里同步", "サーバーを削除しました。このネットワーク内だけで同期します"),
+ ("localNetwork", "Local network", "局域网", "ローカルネットワーク"),
+ ("lanFootnote", "Uses UDP port 8788. If the devices are on different subnets, enter the other device's address when pairing.", "使用 UDP 端口 8788。两台不在同一网段时,配对时输入对方的地址。", "UDP ポート 8788 を使います。2 台が別のサブネットにある場合は、ペアリング時に相手のアドレスを入力します。"),
+ ("lanDiscovery", "Find devices on this network", "在局域网中查找设备", "このネットワークでデバイスを探す"),
+ ("lanDiscoveryDesc", "Pair and sync without a server. Others on the network only see an anonymous entry that changes daily.", "不用服务器就能配对和同步。网络里的其他人只能看到一个每天都变的匿名标识", "サーバーなしでペアリングと同期ができます。ネットワーク上の他の人には、毎日変わる匿名の識別子しか見えません"),
+ ("macLocalNetwork", "Local Network access", "本地网络权限", "ローカルネットワークへのアクセス"),
+ ("macLocalNetworkDesc", "macOS asks once whether CopySync may connect to devices on your network. If you declined, turn on CopySync Daemon there.", "macOS 会问一次是否允许 CopySync 连接网络里的设备。拒绝过的话,到那里打开 CopySync Daemon", "CopySync がネットワーク上のデバイスに接続してよいか、macOS が一度だけ確認します。拒否した場合は、そこで CopySync Daemon をオンにしてください"),
+ ("allowLan", "Windows Firewall", "Windows 防火墙", "Windows ファイアウォール"),
+ ("allowLanDesc", "Allow this when other devices can't reach this one, for example when pairing from another subnet. Asks for administrator approval once.", "其他设备连不上这台时放行,比如从别的网段配对。会请求一次管理员权限", "他のデバイスからこのデバイスに接続できないとき(別のサブネットからのペアリングなど)に許可します。管理者の承認を 1 回求めます"),
+ ("allow", "Allow", "放行", "許可"),
+ ("allowLanDone", "Allowed. Other devices can now reach this one.", "已放行,其他设备现在可以连到这台了", "許可しました。他のデバイスからこのデバイスに接続できます。"),
("deviceName", "Device name", "设备名称", "デバイス名"),
("deviceNameDesc", "Shown in the list on your other devices", "显示在其他设备的列表里", "他のデバイスの一覧に表示されます"),
("language", "Language", "语言", "言語"),
diff --git a/ui/tool/screenshots/screenshots_test.dart b/ui/tool/screenshots/screenshots_test.dart
index ad950a4..e71a112 100644
--- a/ui/tool/screenshots/screenshots_test.dart
+++ b/ui/tool/screenshots/screenshots_test.dart
@@ -34,7 +34,7 @@ final _cjk = _lang == 'ja' ? const ['Hiragino', 'PingFang'] : const ['PingFang']
/// 生成配对码不走后台服务,直接给一个固定值。
class _DemoState extends AppState {
@override
- Future<String> createPairingCode() async => 'K7MP2X';
+ Future<PairingCode> createPairingCode() async => (code: 'K7MP2X', addresses: ['192.168.1.20']);
}
Future<void> _loadFonts() async {
@@ -97,9 +97,11 @@ AppState _demo({LinkState link = LinkState.online,
serviceState: service,
pendingPairing: pending,
status: Status(
- version: '1.3.0',
+ version: '1.4.0',
deviceName: 'MacBook Pro',
- signalingConnected: link == LinkState.online,
+ signalingConnected: link == LinkState.online && server.isNotEmpty,
+ serverConfigured: server.isNotEmpty,
+ lanEnabled: true,
clipboardPermission: ClipboardPermission.CLIPBOARD_PERMISSION_ALWAYS_ALLOW,
cacheBytesUsed: Int64(412 * _mb),
peersOnline: 2,