From e10de8464ae577d0a917482d01e7e01fbaf63460 Mon Sep 17 00:00:00 2001 From: pnwmatt <180812017+pnwmatt@users.noreply.github.com> Date: Sat, 8 Feb 2025 04:04:30 -0800 Subject: [PATCH 01/14] [bug] Add missing `group` property to the Account model (#3746) * Stub out account's Group parameter * Fix typo in Contributing documentation * Update swagger and match style * Update the swagger command to mimic test/swagger.sh * Fix tests for new `group` param in Account model * More test changes for new `group` param in Account * Continuing test changes for `group` param stubbing * Another round of `group` stubbing for tests --- CONTRIBUTING.md | 4 +- docs/api/swagger.yaml | 8 ++ .../api/client/admin/accountsgetv2_test.go | 30 ++-- internal/api/client/admin/reportsget_test.go | 39 ++++-- .../api/client/followrequests/get_test.go | 3 +- .../api/client/instance/instancepatch_test.go | 18 ++- internal/api/client/mutes/mutesget_test.go | 2 +- internal/api/client/reports/reportget_test.go | 3 +- .../api/client/reports/reportsget_test.go | 12 +- .../api/client/statuses/statushistory_test.go | 3 +- .../api/client/statuses/statusmute_test.go | 6 +- internal/api/model/account.go | 2 + .../processing/stream/notification_test.go | 3 +- .../processing/stream/statusupdate_test.go | 3 +- internal/typeutils/internaltofrontend.go | 1 + internal/typeutils/internaltofrontend_test.go | 129 ++++++++++++------ 16 files changed, 180 insertions(+), 86 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4fa148f37..29209dcbf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -149,7 +149,7 @@ In case this post disappears, here are the steps (slightly modified): > > Add your fork as origin: > -> `git remote add origin git@github.com/yourgithubname/gotosocial` +> `git remote add origin git@github.com:yourgithubname/gotosocial` > Be sure to run `git fetch` before building the project for the first time. @@ -489,7 +489,7 @@ You can install go-swagger following the instructions [here](https://goswagger.i If you change Swagger annotations on any of the API paths, you can generate a new Swagger file at `./docs/api/swagger.yaml` by running: ```bash -swagger generate spec --scan-models --exclude-deps -o docs/api/swagger.yaml +go run github.com/go-swagger/go-swagger/cmd/swagger generate spec --scan-models --exclude-deps --output docs/api/swagger.yaml ``` ### CI/CD configuration diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml index ed44a5561..df8f09321 100644 --- a/docs/api/swagger.yaml +++ b/docs/api/swagger.yaml @@ -300,6 +300,10 @@ definitions: format: int64 type: integer x-go-name: FollowingCount + group: + description: Account identifies as a Group actor. + type: boolean + x-go-name: Group header: description: Web location of the account's header image. example: https://example.org/media/some_user/header/original/header.jpeg @@ -2439,6 +2443,10 @@ definitions: format: int64 type: integer x-go-name: FollowingCount + group: + description: Account identifies as a Group actor. + type: boolean + x-go-name: Group header: description: Web location of the account's header image. example: https://example.org/media/some_user/header/original/header.jpeg diff --git a/internal/api/client/admin/accountsgetv2_test.go b/internal/api/client/admin/accountsgetv2_test.go index 489a245d0..0e3eb95e1 100644 --- a/internal/api/client/admin/accountsgetv2_test.go +++ b/internal/api/client/admin/accountsgetv2_test.go @@ -114,7 +114,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -169,7 +170,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -216,7 +218,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false } }, { @@ -266,7 +269,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -313,7 +317,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -360,7 +365,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "statuses_count": 1, "last_status_at": "2023-11-02", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, { @@ -406,7 +412,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, { @@ -453,7 +460,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false } }, { @@ -499,7 +507,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() { "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false } } ]`, dst.String()) @@ -584,7 +593,8 @@ func (suite *AccountsGetTestSuite) TestAccountsMinID() { "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false } } ]`, dst.String()) diff --git a/internal/api/client/admin/reportsget_test.go b/internal/api/client/admin/reportsget_test.go index 255e32c3b..3af187ad2 100644 --- a/internal/api/client/admin/reportsget_test.go +++ b/internal/api/client/admin/reportsget_test.go @@ -189,7 +189,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "target_account": { @@ -247,7 +248,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -302,7 +304,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -357,7 +360,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -429,7 +433,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -476,7 +481,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "assigned_account": null, @@ -525,7 +531,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { @@ -683,7 +690,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -730,7 +738,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "assigned_account": null, @@ -779,7 +788,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { @@ -937,7 +947,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -984,7 +995,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "assigned_account": null, @@ -1033,7 +1045,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { diff --git a/internal/api/client/followrequests/get_test.go b/internal/api/client/followrequests/get_test.go index c36253876..bf16a509e 100644 --- a/internal/api/client/followrequests/get_test.go +++ b/internal/api/client/followrequests/get_test.go @@ -103,7 +103,8 @@ func (suite *GetTestSuite) TestGet() { "statuses_count": 1, "last_status_at": "2023-11-02", "emojis": [], - "fields": [] + "fields": [], + "group": false } ]`, dst.String()) } diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go index 47126e8b5..53df20b6b 100644 --- a/internal/api/client/instance/instancepatch_test.go +++ b/internal/api/client/instance/instancepatch_test.go @@ -191,7 +191,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [ @@ -333,7 +334,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [ @@ -475,7 +477,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [ @@ -668,7 +671,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [ @@ -836,7 +840,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [ @@ -1015,7 +1020,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [ diff --git a/internal/api/client/mutes/mutesget_test.go b/internal/api/client/mutes/mutesget_test.go index 13d826398..f9cfe5d9c 100644 --- a/internal/api/client/mutes/mutesget_test.go +++ b/internal/api/client/mutes/mutesget_test.go @@ -148,7 +148,7 @@ func (suite *MutesTestSuite) TestIndefinitelyMutedAccountSerializesMuteExpiratio // Fetch all muted accounts for the logged-in account. // The expected body contains `"mute_expires_at":null`. - _, err = suite.getMutedAccounts(http.StatusOK, `[{"id":"01F8MH5ZK5VRH73AKHQM6Y9VNX","username":"foss_satan","acct":"foss_satan@fossbros-anonymous.io","display_name":"big gerald","locked":false,"discoverable":true,"bot":false,"created_at":"2021-09-26T10:52:36.000Z","note":"i post about like, i dunno, stuff, or whatever!!!!","url":"http://fossbros-anonymous.io/@foss_satan","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.webp","header_static":"http://localhost:8080/assets/default_header.webp","header_description":"Flat gray background (default header).","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2024-11-01","emojis":[],"fields":[],"mute_expires_at":null}]`) + _, err = suite.getMutedAccounts(http.StatusOK, `[{"id":"01F8MH5ZK5VRH73AKHQM6Y9VNX","username":"foss_satan","acct":"foss_satan@fossbros-anonymous.io","display_name":"big gerald","locked":false,"discoverable":true,"bot":false,"created_at":"2021-09-26T10:52:36.000Z","note":"i post about like, i dunno, stuff, or whatever!!!!","url":"http://fossbros-anonymous.io/@foss_satan","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.webp","header_static":"http://localhost:8080/assets/default_header.webp","header_description":"Flat gray background (default header).","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2024-11-01","emojis":[],"fields":[],"group":false,"mute_expires_at":null}]`) if err != nil { suite.FailNow(err.Error()) } diff --git a/internal/api/client/reports/reportget_test.go b/internal/api/client/reports/reportget_test.go index afbcb2e28..51b80703d 100644 --- a/internal/api/client/reports/reportget_test.go +++ b/internal/api/client/reports/reportget_test.go @@ -133,7 +133,8 @@ func (suite *ReportGetTestSuite) TestGetReport1() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }`, string(b)) } diff --git a/internal/api/client/reports/reportsget_test.go b/internal/api/client/reports/reportsget_test.go index b5988e331..b6c3a0662 100644 --- a/internal/api/client/reports/reportsget_test.go +++ b/internal/api/client/reports/reportsget_test.go @@ -159,7 +159,8 @@ func (suite *ReportsGetTestSuite) TestGetReports() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } } ]`, string(b)) @@ -250,7 +251,8 @@ func (suite *ReportsGetTestSuite) TestGetReports4() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } } ]`, string(b)) @@ -325,7 +327,8 @@ func (suite *ReportsGetTestSuite) TestGetReports6() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } } ]`, string(b)) @@ -384,7 +387,8 @@ func (suite *ReportsGetTestSuite) TestGetReports7() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } } ]`, string(b)) diff --git a/internal/api/client/statuses/statushistory_test.go b/internal/api/client/statuses/statushistory_test.go index 3878f54e4..61c15b58a 100644 --- a/internal/api/client/statuses/statushistory_test.go +++ b/internal/api/client/statuses/statushistory_test.go @@ -120,7 +120,8 @@ func (suite *StatusHistoryTestSuite) TestGetHistory() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "poll": null, "media_attachments": [], diff --git a/internal/api/client/statuses/statusmute_test.go b/internal/api/client/statuses/statusmute_test.go index 66bd4a420..20ee590f8 100644 --- a/internal/api/client/statuses/statusmute_test.go +++ b/internal/api/client/statuses/statusmute_test.go @@ -139,7 +139,8 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "media_attachments": [], "mentions": [], @@ -227,7 +228,8 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "media_attachments": [], "mentions": [], diff --git a/internal/api/model/account.go b/internal/api/model/account.go index a27033d5d..d14ef9047 100644 --- a/internal/api/model/account.go +++ b/internal/api/model/account.go @@ -126,6 +126,8 @@ type Account struct { // If set, indicates that this account is currently inactive, and has migrated to the given account. // Key/value omitted for accounts that haven't moved, and for suspended accounts. Moved *Account `json:"moved,omitempty"` + // Account identifies as a Group actor. + Group bool `json:"group"` } // WebAccount is like Account, but with diff --git a/internal/processing/stream/notification_test.go b/internal/processing/stream/notification_test.go index 5c89e1f40..2ede28079 100644 --- a/internal/processing/stream/notification_test.go +++ b/internal/processing/stream/notification_test.go @@ -82,7 +82,8 @@ func (suite *NotificationTestSuite) TestStreamNotification() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }`, dst.String()) } diff --git a/internal/processing/stream/statusupdate_test.go b/internal/processing/stream/statusupdate_test.go index 6bf5e436c..180538c60 100644 --- a/internal/processing/stream/statusupdate_test.go +++ b/internal/processing/stream/statusupdate_test.go @@ -94,7 +94,8 @@ func (suite *StatusUpdateTestSuite) TestStreamNotification() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 8375a8c3a..446fe1954 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -388,6 +388,7 @@ func (c *Converter) accountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A EnableRSS: enableRSS, HideCollections: hideCollections, Roles: roles, + Group: false, } // Bodge default avatar + header in, diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go index 27b6df139..e749dafe4 100644 --- a/internal/typeutils/internaltofrontend_test.go +++ b/internal/typeutils/internaltofrontend_test.go @@ -72,7 +72,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontend() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }`, string(b)) } @@ -178,8 +179,10 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendAliasedAndMoved() "verified_at": null } ], - "hide_collections": true - } + "hide_collections": true, + "group": false + }, + "group": false }`, string(b)) } @@ -230,7 +233,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiStruct() } ], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }`, string(b)) } @@ -279,7 +283,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiIDs() { } ], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }`, string(b)) } @@ -333,7 +338,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendSensitive() { "color": "", "permissions": "0", "highlighted": false - } + }, + "group": false }`, string(b)) } @@ -370,7 +376,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendPublicPunycode() "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false }`, string(b)) } @@ -409,7 +416,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPubl "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false }`, string(b)) } @@ -448,7 +456,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBloc "statuses_count": 0, "last_status_at": null, "emojis": [], - "fields": [] + "fields": [], + "group": false }`, string(b)) } @@ -516,7 +525,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { "name": "admin", "color": "" } - ] + ], + "group": false }, "media_attachments": [ { @@ -695,7 +705,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() { "name": "admin", "color": "" } - ] + ], + "group": false }, "media_attachments": [ { @@ -879,7 +890,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "media_attachments": [ { @@ -1014,7 +1026,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { "name": "admin", "color": "" } - ] + ], + "group": false }, "media_attachments": [], "mentions": [], @@ -1301,7 +1314,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments "statuses_count": 1, "last_status_at": "2023-11-02", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { @@ -1466,7 +1480,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() { "statuses_count": 1, "last_status_at": "2023-11-02", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { @@ -1608,7 +1623,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage() "name": "admin", "color": "" } - ] + ], + "group": false }, "media_attachments": [ { @@ -1748,7 +1764,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendPartialInteraction "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "media_attachments": [], "mentions": [], @@ -1863,7 +1880,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval() "name": "admin", "color": "" } - ] + ], + "group": false }, "media_attachments": [], "mentions": [ @@ -2075,7 +2093,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() { "name": "admin", "color": "" } - ] + ], + "group": false }, "max_toot_chars": 5000, "rules": [], @@ -2227,7 +2246,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() { "name": "admin", "color": "" } - ] + ], + "group": false } }, "rules": [], @@ -2340,7 +2360,8 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }`, string(b)) } @@ -2396,7 +2417,8 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend2() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false } }`, string(b)) } @@ -2461,7 +2483,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "target_account": { @@ -2519,7 +2542,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -2574,7 +2598,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -2629,7 +2654,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -2711,7 +2737,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG" }, @@ -2758,7 +2785,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "assigned_account": null, @@ -2807,7 +2835,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false }, "media_attachments": [ { @@ -2966,7 +2995,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "statuses_count": 4, "last_status_at": "2024-11-01", "emojis": [], - "fields": [] + "fields": [], + "group": false } }, "target_account": { @@ -3014,7 +3044,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "emojis": [], "fields": [], "suspended": true, - "hide_collections": true + "hide_collections": true, + "group": false } }, "assigned_account": { @@ -3068,7 +3099,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -3123,7 +3155,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "name": "admin", "color": "" } - ] + ], + "group": false }, "created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F" }, @@ -3270,7 +3303,8 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "name": "admin", "color": "" } - ] + ], + "group": false }, "status": { "id": "01F8MHC8VWDRBQR0N1BATDDEM5", @@ -3331,7 +3365,8 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false }, "media_attachments": [], "mentions": [], @@ -3421,7 +3456,8 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "name": "admin", "color": "" } - ] + ], + "group": false }, "media_attachments": [], "mentions": [ @@ -3531,7 +3567,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false } ], "last_status": { @@ -3585,7 +3622,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "media_attachments": [], "mentions": [], @@ -3698,7 +3736,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() { "verified_at": null } ], - "hide_collections": true + "hide_collections": true, + "group": false } ], "last_status": { @@ -3752,7 +3791,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "media_attachments": [], "mentions": [], @@ -3837,7 +3877,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "poll": null, "media_attachments": [], @@ -3873,7 +3914,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "poll": null, "media_attachments": [], @@ -3909,7 +3951,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() { "last_status_at": "2024-11-01", "emojis": [], "fields": [], - "enable_rss": true + "enable_rss": true, + "group": false }, "poll": null, "media_attachments": [], From 2aa3524739a5472da40603c9a03178fe9f7a1ea0 Mon Sep 17 00:00:00 2001 From: CDN Date: Sun, 9 Feb 2025 18:12:46 +0800 Subject: [PATCH 02/14] [chore] fix typo in docs (#3758) * [chore] fix link reference in docs/admin/settings.md * [docs] fix typo in docs/federation/posts.md --- docs/admin/settings.md | 2 +- docs/federation/posts.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/admin/settings.md b/docs/admin/settings.md index 37581e177..524b7d5c4 100644 --- a/docs/admin/settings.md +++ b/docs/admin/settings.md @@ -253,4 +253,4 @@ custom CSS allows you to further customize the way your instance looks when visi This custom CSS will be applied to all pages of your instance. Users themes and CSS still take precedence over this customization. -See the [Custom CSS](./custom_css.md) page for some tips on writing custom CSS for your instance. +See the [Custom CSS](../user_guide/custom_css.md) page for some tips on writing custom CSS for your instance. diff --git a/docs/federation/posts.md b/docs/federation/posts.md index 345834a23..598f52131 100644 --- a/docs/federation/posts.md +++ b/docs/federation/posts.md @@ -79,7 +79,7 @@ For example: "updated": "2022-11-17T11:36:05Z" } [...] -}` +} ``` The text `:shocked_pikachu:` in the `content` of the above `Note` should be replaced by clients with a small (inline) version of the emoji image, when rendering the `Note` and displaying it to users. From 62f25ea08aa5d537ab5a207c2325812b35da1f3a Mon Sep 17 00:00:00 2001 From: CDN Date: Sun, 9 Feb 2025 18:13:08 +0800 Subject: [PATCH 03/14] [docs/zh] Update zh docs: synced to e10de84 (#3763) * [docs/zh] Update zh docs: synced to e10de84 * [docs/zh] update mkdocs config of zh docs * [docs/zh] update repo docs translations (README, ROADMAP, CONTRIBUTING) + update swagger schema metadata of docs/zh --- docs/locales/zh/admin/backup_and_restore.md | 12 +- docs/locales/zh/admin/cli.md | 18 +- docs/locales/zh/admin/database_maintenance.md | 4 +- docs/locales/zh/admin/domain_blocks.md | 4 +- .../admin/domain_permission_subscriptions.md | 145 ++ docs/locales/zh/admin/federation_modes.md | 8 +- docs/locales/zh/admin/media_caching.md | 6 +- .../zh/admin/request_filtering_modes.md | 4 +- docs/locales/zh/admin/robots.md | 4 + docs/locales/zh/admin/settings.md | 97 +- docs/locales/zh/admin/signups.md | 4 +- docs/locales/zh/admin/spam.md | 4 +- docs/locales/zh/advanced/caching/index.md | 2 +- docs/locales/zh/advanced/certificates.md | 4 +- docs/locales/zh/advanced/healthchecks.md | 4 +- .../zh/advanced/host-account-domain.md | 6 +- docs/locales/zh/advanced/security/index.md | 2 +- .../zh/advanced/sqlite-networked-storage.md | 2 +- docs/locales/zh/api/authentication.md | 6 +- docs/locales/zh/api/ratelimiting.md | 4 +- docs/locales/zh/api/swagger.md | 2 +- docs/locales/zh/api/swagger.yaml | 1211 ++++++++++++++++- docs/locales/zh/configuration/general.md | 4 +- docs/locales/zh/configuration/instance.md | 43 + docs/locales/zh/configuration/oidc.md | 2 +- .../zh/configuration/trusted_proxies.md | 171 +++ docs/locales/zh/federation/actors.md | 8 + docs/locales/zh/federation/posts.md | 58 +- docs/locales/zh/getting_started/index.md | 16 +- .../getting_started/installation/container.md | 4 +- .../zh/getting_started/installation/metal.md | 4 +- .../reverse_proxy/apache-httpd.md | 4 +- .../zh/getting_started/reverse_proxy/index.md | 6 +- .../zh/getting_started/reverse_proxy/nginx.md | 6 +- .../zh/getting_started/user_creation.md | 2 +- docs/locales/zh/mkdocs.yml | 2 + docs/locales/zh/repo/CONTRIBUTING.md | 4 +- docs/locales/zh/repo/README.md | 13 +- docs/locales/zh/repo/ROADMAP.md | 2 +- docs/locales/zh/user_guide/migration.md | 8 +- docs/locales/zh/user_guide/posts.md | 9 +- docs/locales/zh/user_guide/settings.md | 22 +- 42 files changed, 1789 insertions(+), 152 deletions(-) create mode 100644 docs/locales/zh/admin/domain_permission_subscriptions.md create mode 100644 docs/locales/zh/configuration/trusted_proxies.md diff --git a/docs/locales/zh/admin/backup_and_restore.md b/docs/locales/zh/admin/backup_and_restore.md index 2a5b50bf1..34b0d805e 100644 --- a/docs/locales/zh/admin/backup_and_restore.md +++ b/docs/locales/zh/admin/backup_and_restore.md @@ -134,14 +134,14 @@ GoToSocial CLI 工具还提供了从实例备份和恢复数据的命令,这 * 备份是加密的。 * 内置工具可以列出快照并从中恢复。 -!!! tip +!!! tip "提示" [Rsync.net](https://rsync.net/)、[BorgBase](https://www.borgbase.com/) 和 [Hetzner Storage](https://www.hetzner.com/storage/storage-box) 提供了可用于备份的经济实惠的存储。Rsync.net 有一种专门为 Borg 设计的备份产品,比他们的常规存储产品便宜得多。如果你只想使用 Borg 管理的备份,请在[此处注册](https://www.rsync.net/products/borg.html)。 #### Borgmatic [Borgmatic](https://torsion.org/borgmatic/) 是一个帮助使用 [Borg](https://www.borgbackup.org/) 进行备份的工具。它通过使用 YAML 的声明性配置文件驱动。BorgBase、Rsync.net 和 Hetzner 都支持 Borg。 -!!! warning +!!! warning "警告" 初始化 Borg 仓库时,确保使用强加密密钥进行设置,并将密钥安全地存放在某处。否则将无法在将来解密备份。ArchWiki 上关于 Borgmatic 的条目解释了如何安全地将你的加密密钥传递给 Borgmatic,而不在配置文件中以明文形式存储它。 如何使用 Borgmatic 备份数据库有其[单独的文档页面](https://torsion.org/borgmatic/docs/how-to/backup-your-databases/),你应当在备份前查看一下。对于使用 SQLite 的 GoToSocial,Borgmatic 的简单 `config.yaml` 如下: @@ -182,11 +182,11 @@ hooks: 您需要将该文件放在您的 GoToSocial 实例上,并确保该文件是可执行的。它需要 Python 3,安装 Borg 和 Borgmatic 后您应该已经具备。它仅依赖于 Python 标准库。 -!!! note +!!! note "注意" 为了确保可靠运行,您应确保 GoToSocial 配置中的 [storage-local-base-path](../configuration/storage.md) 使用的是绝对路径。否则您将需要自己调整路径。 ```sh -$ gotosocial admin media list-attachments --local-only | \ +$ gotosocial --config-path /path/to/config.yaml admin media list-attachments --local-only | \ /path/to/media-to-borg-patterns.py \ ``` @@ -199,7 +199,7 @@ R - /* ``` -!!! tip +!!! tip "提示" 你可以通过向 `media-to-borg-patterns.py` 传递 `--help` 来查看帮助。通过将文件位置作为脚本的最后一个参数,也可以将输出直接写入文件。 给定这组模式,Borg 将从 `` 开始寻找文件。任何匹配路径前缀 `pp:` 的都会被包括进去。其他的则会匹配最后一个模式,从存档中排除。 @@ -211,7 +211,7 @@ R ```ini [Service] -ExecStartPre=/path/to/gotosocial admin media list-attachments --local-only | /path/to/media-to-borg-patterns.py /etc/borgmatic/gotosocial_patterns +ExecStartPre=/path/to/gotosocial --config-path /path/to/config.yaml admin media list-attachments --local-only | /path/to/media-to-borg-patterns.py /etc/borgmatic/gotosocial_patterns ``` 建议查看的文档: diff --git a/docs/locales/zh/admin/cli.md b/docs/locales/zh/admin/cli.md index 24ea8745b..5fa279994 100644 --- a/docs/locales/zh/admin/cli.md +++ b/docs/locales/zh/admin/cli.md @@ -27,13 +27,13 @@ GoToSocial - 一个联邦制社交媒体服务器 在 `可用命令` 下,可以看到标准的 `server` 命令。但是也有处理管理和调试的命令,这些将在本文档中进行解释。 -!!! Info "将全局配置传递给 CLI" +!!! info "将全局配置传递给 CLI" 对于所有这些命令,你仍然需要正确设置全局选项,以便 CLI 工具知道如何连接到你的数据库,以及使用哪个数据库、哪个主机和账户域等。 你可以使用环境变量设置这些选项,通过 CLI 标志传递它们(例如,`gotosocial [commands] --host example.org`),或者只需将 CLI 工具指向你的配置文件(例如,`gotosocial --config-path ./config.yaml [commands]`)。 -!!! Info +!!! info "附注" 运行 CLI 命令时,你将会看到如下输出: @@ -45,7 +45,7 @@ GoToSocial - 一个联邦制社交媒体服务器 这是正常的,表示命令已按预期运行。 -!!! Warning "运行管理命令后重启 GtS" +!!! warning "运行管理命令后重启 GtS" 由于 GoToSocial 的内部缓存机制,你可能需要在运行某些命令后重启 GoToSocial,以使命令的效果“生效”。我们仍在寻找一种无需重启的方法。在此期间,需要在运行命令后重启的命令将在下文中突出显示。 @@ -86,7 +86,7 @@ gotosocial admin account create \ 此命令可用于确认你的实例上的用户+账户,允许他们登录并使用账户。 -!!! Info +!!! info "附注" 如果账户是使用 `admin account create` 创建的,则不必在账户上运行 `confirm`,它将已被确认。 @@ -113,7 +113,7 @@ gotosocial admin account confirm --username some_username --config-path config.y 此命令可用于将用户提升为管理员。 -!!! Warning "需要重启服务器" +!!! warning "需要重启服务器" 为使更改生效,此命令需要在运行命令后重启 GoToSocial。 @@ -140,7 +140,7 @@ gotosocial admin account promote --username some_username --config-path config.y 此命令可用于将用户从管理员降级为普通用户。 -!!! Warning "需要重启服务器" +!!! warning "需要重启服务器" 为使更改生效,此命令需要在运行命令后重启 GoToSocial。 @@ -167,7 +167,7 @@ gotosocial admin account demote --username some_username --config-path config.ya 此命令可用于在你的实例上禁用一个账户:禁止其登录或执行任何操作,但不删除数据。 -!!! Warning "需要重启服务器" +!!! warning "需要重启服务器" 为使更改生效,此命令需要在运行命令后重启 GoToSocial。 @@ -194,7 +194,7 @@ gotosocial admin account disable --username some_username --config-path config.y 此命令可用于重新启用你实例上的账户,撤销之前的 `disable` 命令。 -!!! Warning "需要重启服务器" +!!! warning "需要重启服务器" 为使更改生效,此命令需要在运行命令后重启 GoToSocial。 @@ -221,7 +221,7 @@ gotosocial admin account enable --username some_username --config-path config.ya 此命令可用于为指定的本站账户设置新密码。 -!!! Warning "需要重启服务器" +!!! warning "需要重启服务器" 为使更改生效,此命令需要在运行命令后重启 GoToSocial。 diff --git a/docs/locales/zh/admin/database_maintenance.md b/docs/locales/zh/admin/database_maintenance.md index 36b0159bb..025d7c93a 100644 --- a/docs/locales/zh/admin/database_maintenance.md +++ b/docs/locales/zh/admin/database_maintenance.md @@ -2,11 +2,11 @@ 无论你选择使用 SQLite 还是 Postgres 来运行 GoToSocial,可能都需要偶尔执行一些维护工作,以保持数据库的良好运作。 -!!! tip +!!! tip "提示" 尽管此处提供的维护建议旨在不破坏现有数据,你还是应该在手动执行维护操作之前备份数据库。这样,如果输入错误或意外运行了不当命令,可以恢复备份并重试。 -!!! danger +!!! danger "危险" **强烈不建议**手动创建、删除或更新 GoToSocial 数据库中的条目,这里不会提供相关命令。即使你认为自己知道在做什么,运行 `DELETE` 等语句可能会引入非常难以排查的问题。以下维护建议旨在帮助你的实例平稳运行;如果你手动进入数据库并对条目、表和索引进行修改,它们不会拯救你的数据。 diff --git a/docs/locales/zh/admin/domain_blocks.md b/docs/locales/zh/admin/domain_blocks.md index 00be4d3f8..48f4b1249 100644 --- a/docs/locales/zh/admin/domain_blocks.md +++ b/docs/locales/zh/admin/domain_blocks.md @@ -2,7 +2,7 @@ GoToSocial 支持屏蔽/封禁那些你不想与你的实例联合的域名。在我们的文档中,“屏蔽”和“封禁”这两个术语在涉及域名时可以互换使用,因为它们的意思相同:屏蔽你的实例与目标域名上的实例相互通信,有效地切断两个实例之间的联合。 -你可以使用[实例管理面板](./settings.md#联合)查看、创建和移除域名屏蔽和域名允许。 +你可以使用[实例管理面板](./settings.md#域名权限)查看、创建和移除域名屏蔽和域名允许。 本文档重点说明域名屏蔽实际*作用*是什么,以及创建新域名屏蔽时会产生哪些副作用。 @@ -54,7 +54,7 @@ GoToSocial 支持屏蔽/封禁那些你不想与你的实例联合的域名。 3. 删除封禁帐户的所有贴文。 4. 删除封禁帐户及其贴文的所有媒体,包括媒体附件、头像、头图和表情符号。 -!!! danger +!!! danger "危险" 目前,上述大多数副作用是**不可逆**的。如果你在屏蔽后取消屏蔽一个域名,该域名上的所有帐户将不再被标记为已封禁,并且你将能够再次与他们互动,但所有关系仍将被清除,所有贴文和媒体将被删除。 在屏蔽一个域名之前请仔细考虑。 diff --git a/docs/locales/zh/admin/domain_permission_subscriptions.md b/docs/locales/zh/admin/domain_permission_subscriptions.md new file mode 100644 index 000000000..cf211aa90 --- /dev/null +++ b/docs/locales/zh/admin/domain_permission_subscriptions.md @@ -0,0 +1,145 @@ +# 域名权限订阅 + +你可以通过[管理设置面板](./settings.md#订阅)创建和管理域名权限订阅。 + +域名权限订阅允许你指定一个域名权限列表托管的URL。默认情况下,每24小时在当前时区晚上11点进行自动更新,你的实例将获取并解析你订阅的每个列表,基于在列表中发现的条目,按照优先级(从高到低)顺序创建域(或域名权限草稿)。 + +每个域名权限订阅可以用来创建域名允许或域名阻止条目。 + +!!! warning "警告" + 目前,通过阻止列表订阅只能创建“屏蔽”级别的域名阻止条目;其他严重程度尚不支持。订阅阻止列表中严重程度为“隐藏”或“限制”等的条目将被跳过。 + +## 优先级 + +当存在多个域名权限订阅时,它们将按照优先级顺序(从最高优先级(255)到最低优先级(0))被获取和解析。 + +在优先级较高的列表上发现的权限条目将覆盖优先级较低的列表上的权限条目。 + +例如,一名实例管理员订阅了两个允许列表,“重要列表”优先级为255,“不太重要的列表”优先级为128。每个订阅列表都包含了`good-eggs.example.org`的条目。 + +那么优先级较高的订阅会负责创建和管理`good-eggs.example.org`的域名允许条目。 + +如果移除了优先级较高的订阅,那么下次获取所有订阅时,“不太重要的列表”将创建(或接管)该域名允许条目。 + +## 孤立权限 + +目前没有被域名权限订阅管理的域名权限条目(阻止条目和允许条目)被认为是“孤立”权限。这包括管理员手动在设置面板中创建的权限,或者是通过导入/导出页面手动导入的权限。 + +如果你愿意,在创建域名权限订阅时,可以将该订阅的[“接管孤立权限条目”](./settings.md#接管孤立权限条目)设置为 true。如果一个启用了“接管孤立权限条目”的域名权限订阅遇到一个孤立权限,并且该条目 *也在该订阅地址指向的列表中*,那么它将把该孤立条目的订阅ID设置为其自身ID,来“接收”此孤立条目。 + +例如,一个实例管理员手动为域名`horrid-trolls.example.org`创建了域名阻止条目。稍后,他们创建了一个域名阻止列表订阅,并将“收养孤儿”设置为真,且该订阅包含`horrid-trolls.example.org`。当实例获取并解析列表,并从中创建域名权限条目时,`horrid-trolls.example.org`这个孤立的域名阻止条目将被刚刚配置的域名权限订阅接收。现在,如果域名权限订阅被移除,且在移除时勾选了移除订阅所拥有的所有权限选项,那么`horrid-trolls.example.org`这个域名阻止条目也将被移除。 + +## 域名权限订阅的几种有趣的应用场景 + +### 1. 创建白名单联合实例集群 + +域名权限订阅使得创建白名单联合实例集群集群变得更加容易,也就是说,一组实例理论上可以形成自己的迷你联邦宇宙,每个实例在[白名单联合模式](./federation_modes.md#白名单联合模式)下运行,并订阅同一个合作管理的、托管在某处的允许列表。 + +例如,实例 `instance-a.example.org`、`instance-b.example.org` 和 `instance-c.example.org` 决定他们只想彼此联合。 + +他们可以使用像 GitHub 这样的版本管理平台托管一个纯文本格式的允许列表,比如在 `https://raw.githubusercontent.com/our-cluster/allowlist/refs/heads/main/allows.txt`。 + +纯文本格式的允许列表内容如下: + +```text +instance-a.example.org +instance-b.example.org +instance-c.example.org +``` + +每个实例管理员都将他们的联合模式设置为`白名单`,并创建一个类型为“允许”,订阅地址为 `https://raw.githubusercontent.com/our-cluster/allowlist/refs/heads/main/allows.txt` 的订阅,这会为他们自己的域名以及集群中的其他域名创建域名允许条目。 + +在某个时候,来自 `instance-d.example.org` 的某人(在站外)申请被添加到集群中。现有的管理员同意,并更新他们的纯文本格式允许列表为: + +```text +instance-a.example.org +instance-b.example.org +instance-c.example.org +instance-d.example.org +``` + +下次每个实例获取列表时,将为 `instance-d.example.org` 创建一个新的域名允许条目,它将能够与该列表中的其他域进行联合。 + +### 2. 合作管理阻止列表 + +域名权限订阅使得合作管理和订阅共享的、包含非法/极右/其他不良账户和内容的域名的阻止列表变得容易。 + +例如,实例 `instance-e.example.org`、`instance-f.example.org` 和 `instance-g.example.org` 的管理员认定:他们厌倦了通过与坏人玩打地鼠游戏来重复工作。为了让生活更轻松,他们决定合作开发一个共享的阻止列表。 + +他们使用像 GitHub 这样的版本管理平台在类似 `https://raw.githubusercontent.com/baddies/blocklist/refs/heads/main/blocks.csv` 的地方托管一个阻止列表。 + +当有人发现另一个他们不喜欢的实例时,他们可以通过合并请求或类似方法添加这个有问题的实例到域名列表中。 + +例如,有人从一个新实例 `fashy-arseholes.example.org` 收到一个不愉快的回复。他们使用他们的协作工具,建议将 `fashy-arseholes.example.org` 添加到阻止列表。经过一些审议和讨论后,该域被添加到列表中。 + +下次 `instance-e.example.org`、`instance-f.example.org` 和 `instance-g.example.org` 获取阻止列表时,将为 `fashy-arseholes.example.org` 创建一个阻止条目。 + +### 3. 订阅阻止列表,但忽略其中的一部分 + +假设上一节中的 `instance-g.example.org` 认定他们同意大部分协作策划的阻止列表,但出于某种原因,他们实际上希望继续与 `fashy-arseholes.example.org` 联合。 + +这可以通过以下三种方法实现: + +1. `instance-g.example.org` 的管理员订阅共享阻止列表,但他们将其["创建为草稿"](./settings.md#将此条目设为草稿)选项设置为 true。当他们的实例获取阻止列表时,会为 `fashy-arseholes.example.org` 创建一个阻止条目草稿。`instance-g` 的管理员只需将权限保留为草稿或拒绝它,因此它永远不会生效。 +2. 在重新获取阻止列表之前,`instance-g.example.org` 的管理员为 `instance-g.example.org` 创建一个[域名权限例外](./settings.md#例外)条目。设置保存后,域名权限订阅将无法`instance-g.example.org` 域名创建权限,因此在列表下次被获取时,共享阻止列表上对于 `instance-g.example.org` 的阻止不会在 `instance-g.example.org` 的实例数据库中创建。 +3. `instance-g.example.org` 的管理员在其实例上为 `fashy-arseholes.example.org` 创建一个显式的域名允许条目。`instance-g` 实例在`黑名单`联合模式下运行,因此[显式允许条目将覆盖域名阻止条目](./federation_modes.md#黑名单模式)。`fashy-arseholes` 域名将保持未被阻止的状态。 + +### 4. 直接订阅另一个实例的阻止列表 + +GoToSocial 能够获取和解析 JSON 格式的域名权限列表,所以可以通过他们的 `/api/v1/instance/domain_blocks` (Mastodon) 或 `/api/v1/instance/peers?filter=suspended` (GoToSocial)端点(如果已公开)直接订阅另一个实例的屏蔽列表。 + +例如,Mastodon 实例 `peepee.poopoo.example.org` 公开他们的阻止列表,而GoToSocial实例的所有者 `instance-h.example.org` 认定他们非常喜欢该 Mastodon 管理员的标准。他们创建一个JSON类型的域名权限订阅,并将地址设为 `https://peepee.poopoo.example.org/api/v1/instance/domain_blocks`。他们的实例将每24小时获取一次对方 Mastodon 实例的阻止列表JSON,并根据其中发现的条目创建权限。 + +## 域名权限订阅列表的格式示例 + +以下是 GoToSocial 能够解析的不同权限列表格式的示例。 + +每个列表包含三个域,`bumfaces.net`、`peepee.poopoo` 和 `nothanks.com`。 + +### CSV + +CSV列表使用内容类型 `text/csv`。 + +Mastodon域名权限通常使用这种格式导出。 + +```csv +#domain,#severity,#reject_media,#reject_reports,#public_comment,#obfuscate +bumfaces.net,suspend,false,false,这个实例上有坏蛋,false +peepee.poopoo,suspend,false,false,骚扰,false +nothanks.com,suspend,false,false,,false +``` + +### JSON (application/json) + +JSON列表使用内容类型 `application/json`。 + +```json +[ + { + "domain": "bumfaces.net", + "suspended_at": "2020-05-13T13:29:12.000Z", + "public_comment": "这个实例上有坏蛋" + }, + { + "domain": "peepee.poopoo", + "suspended_at": "2020-05-13T13:29:12.000Z", + "public_comment": "骚扰" + }, + { + "domain": "nothanks.com", + "suspended_at": "2020-05-13T13:29:12.000Z" + } +] +``` + +### 纯文本 (text/plain) + +纯文本列表使用内容类型 `text/plain`。 + +注意在纯文本列表中无法包含像“obfuscate”或“public comment”这样的字段,因为它们只是一个以换行符分隔的域名列表。 + +```text +bumfaces.net +peepee.poopoo +nothanks.com +``` diff --git a/docs/locales/zh/admin/federation_modes.md b/docs/locales/zh/admin/federation_modes.md index abe9fa095..f408229b2 100644 --- a/docs/locales/zh/admin/federation_modes.md +++ b/docs/locales/zh/admin/federation_modes.md @@ -10,12 +10,12 @@ GoToSocial 当前提供“黑名单”和“白名单”联合模式,可以通 当你的实例遇到它以前未见过的贴文或账户的提及或公告时,如果该资源的域未通过域屏蔽条目被屏蔽,它将会去获取该资源。 -!!! info +!!! info "附注" 黑名单联合模式是 GoToSocial 的默认联合模式。它也是大多数其他 ActivityPub 服务器实现的默认联合模式。 ## 白名单联合模式 -!!! warning +!!! warning "警告" 白名单联合模式仍然被认为是“实验性”的,我们正在研究其在实际中的表现。它应该如其名称所示,但可能会在其他地方导致错误或出现边缘情况,我们还不确定! 当 `instance-federation-mode` 设置为 `allowlist` 时,你的实例将仅与通过设置面板明确设为允许的实例联合,并限制任何未被允许的实例的访问。 @@ -24,7 +24,7 @@ GoToSocial 当前提供“黑名单”和“白名单”联合模式,可以通 当你的实例遇到它以前未见过的贴文或账户的提及或公告时,它只会在资源所属域名被明确允许时才去获取资源。 -!!! tip +!!! tip "提示" 白名单联合模式在你希望仅与选择的“可信”实例联合的情况下非常有用。然而,这会影响发现过程。在黑名单联合模式下,你会通过转发和回复自然地遇到未知实例的贴文和账户,但在白名单联合模式下,这样的偶然发现不会发生。 因此,建议你要么先从黑名单联合模式开始,然后在确定喜欢哪些其他实例后切换到白名单联合模式,要么从白名单联合模式开始,并在首次启动实例后准备好并导入白名单,以便“启动”它。 @@ -54,7 +54,7 @@ GoToSocial 当前提供“黑名单”和“白名单”联合模式,可以通 如果上述任何条件不满足,请求将被拒绝。 -!!! danger +!!! danger "危险" 结合屏蔽和允许是一项棘手的工作! 在导入允许和黑名单时,你应该始终手动审核列表,以确保不会无意中屏蔽你不想屏蔽的实例,因为这可能会有**非常烦人的副作用**,例如移除关注/被关注、贴文等。 diff --git a/docs/locales/zh/admin/media_caching.md b/docs/locales/zh/admin/media_caching.md index d33e73358..b8180ba47 100644 --- a/docs/locales/zh/admin/media_caching.md +++ b/docs/locales/zh/admin/media_caching.md @@ -47,11 +47,11 @@ GoToSocial 提供了三个变量,让你(管理员)可以调节何时以及 上述设置意味着从午夜开始每8小时,GoToSocial 将清除任何缓存超过1天(24小时)的媒体。清理任务将在 00:00、08:00 和 16:00,即午夜、上午8点和下午4点运行。使用此配置,你可能将外站媒体在存储中保留的最长时间约为32小时。 -!!! tip +!!! tip "提示" 将 `media-remote-cache-days` 设置为0或更小意味着外站媒体将永不被清除。然而,本站孤立媒体的清理任务和其他一致性检查仍将按其他变量定义的计划运行。 -!!! tip +!!! tip "提示" 如果你愿意,你也可以通过管理面板手动执行一次性清理操作([查看文档](./settings.md#媒体))。 -!!! warning +!!! warning "警告" 将 `media-cleanup-every` 设置为非常小的值,如 `"30m"` 或更小,可能会导致你的实例不断遍历附件,导致数据使用率高而效益甚微。我们不建议将该值设置为小于约 `"8h"`,即便如此,可能也显得过度。 diff --git a/docs/locales/zh/admin/request_filtering_modes.md b/docs/locales/zh/admin/request_filtering_modes.md index 435fa9386..dbab419b6 100644 --- a/docs/locales/zh/admin/request_filtering_modes.md +++ b/docs/locales/zh/admin/request_filtering_modes.md @@ -2,7 +2,7 @@ GoToSocial 当前提供“屏蔽”、“允许”和禁用的 HTTP 请求头过滤模式,可以通过在 config.yaml 中设置 `advanced-header-filter-mode`,或使用环境变量 `GTS_ADVANCED_HEADER_FILTER_MODE` 来配置。这些模式的具体说明如下。 -!!! warning +!!! warning "警告" HTTP 请求头过滤是一个进阶设置。如果你不熟悉 HTTP 请求头的使用和复杂性,修改这些设置可能会导致联合功能中断,甚至无法访问你自己的实例。 HTTP 请求头过滤仍被视为“实验性”功能。它应该能如预期工作,但可能会导致其他地方出现错误或边缘情况,这点我们尚不确定! @@ -27,5 +27,5 @@ GoToSocial 当前提供“屏蔽”、“允许”和禁用的 HTTP 请求头过 在允许模式下,请求只有在被明确允许且未被明确屏蔽的情况下才会被接受。 -!!! danger +!!! danger "危险" 允许过滤模式是一个极为严格的模式,几乎肯定会阻止许多(合法的)客户端访问你的实例,包括你自己。只有在完全明确你的目标时才应启用此模式。 diff --git a/docs/locales/zh/admin/robots.md b/docs/locales/zh/admin/robots.md index 89a3d4c2d..3d5dfdffd 100644 --- a/docs/locales/zh/admin/robots.md +++ b/docs/locales/zh/admin/robots.md @@ -2,6 +2,10 @@ GoToSocial 在主域名上提供一个 `robots.txt` 文件。该文件包含试图屏蔽已知 AI 爬虫的一些规则,以及其他一些索引器。它还包括一些规则,以确保诸如 API 端点之类的内容不会被搜索引擎索引,因为这些内容没有被索引的必要。 +## 允许/禁止统计数据收集 + +你可以通过修改配置 `instance-stats-mode` 来允许或禁止爬虫从 `/nodeinfo/2.0` 和 `/nodeinfo/2.1` 端点收集你的实例的统计数据,此设置会修改 `robots.txt` 文件。更多详情请参见 [实例配置](../configuration/instance.md)。 + ## AI 爬虫 AI 爬虫来自一个[社区维护的仓库][airobots]。目前是手动保持同步的。如果你知道有任何遗漏的爬虫,请给他们提交一个 PR! diff --git a/docs/locales/zh/admin/settings.md b/docs/locales/zh/admin/settings.md index ea300a432..51068ea94 100644 --- a/docs/locales/zh/admin/settings.md +++ b/docs/locales/zh/admin/settings.md @@ -34,11 +34,11 @@ GoToSocial 管理设置面板使用 [管理 API](https://docs.gotosocial.org/zh- 你可以使用此部分搜索账户并对其执行管理操作。 -### 联合 +### 域名权限 ![已封禁实例列表,有一个字段用于过滤/添加新的屏蔽。下面是批量导入/导出界面的链接](../public/admin-settings-federation.png) -在联合部分,你可以创建、删除和审核明确的域名屏蔽和域名允许。 +在域名权限部分,你可以创建、删除和查看域名阻止条目、域名允许条目、草稿、排除项和订阅。 关于联合设置的更多详细信息,特别是域名允许和域名屏蔽如何结合使用,请参阅 [联合模式部分](./federation_modes.md) 和 [域名屏蔽部分](./domain_blocks.md)。 @@ -46,20 +46,99 @@ GoToSocial 管理设置面板使用 [管理 API](https://docs.gotosocial.org/zh- 你可以在搜索字段中输入一个要封禁的域名,这将过滤列表以显示你是否已有该域名的屏蔽条目。 -点击“封禁”会显示一个表单,允许你添加公开和/或私人评论,并提交以添加屏蔽。添加封禁后,该实例上的所有已知账户将被封禁,并阻止与该被屏蔽实例上的任何用户的新互动。 +点击“封禁”会显示一个表单,允许你添加公开和/或私人评论,并提交以添加屏蔽。 + +添加封禁后,该实例上的所有已知账户将被封禁,并阻止与该被屏蔽实例上的任何用户的新互动。 #### 域名允许 域名允许部分的工作方式与域名屏蔽部分类似,只是用于明确的域名允许而不是域名屏蔽。 -#### 批量导入/导出 +#### 导入/导出 -通过联合部分底部的链接(或访问 `/settings/admin/federation/import-export`),你可以批量导入/导出屏蔽列表和允许列表。 +你可以在这一部分批量导入/导出JSON、CSV或纯文本格式的域名权限条目。 ![导入中包含的域列表,提供选择某些或全部域的方法,更改其域,以及更新子域使用方法。](../public/admin-settings-federation-import-export.png) 通过输入字段或文件导入列表后,你可以在导入子集之前查看列表中的条目。你还会在使用子域的条目中收到警告,此处还提供一种轻松将其更改为主域的方法。 +#### 草稿 + +在这一部分,你可以创建、搜索、接受和拒绝域名权限草稿。 + +域名权限草稿是已被提议,但尚未生效的域域名权限条目(可以手动创建或从已订阅的阻止/允许列表中添加)。 + +在接受前,域名权限草稿将对目标域名的联合没有任何影响。一旦被接受,它将被转换为域名阻止条目或域名允许条目,并开始执行。 + +#### 例外 + +在这一部分,您可以创建、搜索和移除域名权限例外条目。 + +域名权限例外可以防止某域名(及其所有子域)的权限被域名权限订阅自动管理。 + +例如,如果你为域名 `example.org` 创建例外条目,那么在创建域名权限草稿和域名阻止/允许条目时,阻止列表或允许列表订阅将排除 `example.org` 及其任何子域(如 `sub.example.org`,`another.sub.example.org` 等)的条目。 + +此功能可以让你在明确知道是否要与某个域名进行联合的情况下,手动管理被设为例外的域名的权限,不受域名权限订阅中包含的条目的影响。 + +请注意,仅针对某个域名创建排除条目本身并不会对与该域名的联合产生影响,它只有与权限订阅结合使用时才会发挥作用。 + +#### 订阅 + +在这一部分,你可以创建、搜索、编辑、测试和移除域名权限订阅。 + +域名权限订阅允许您指定权限列表的托管地址。默认情况下,每天晚上11点,你的实例将获取并解析订阅的每个列表,并根据列表中的条目创建域名权限(或域名权限草稿)。 + +##### 标题 + +您可以选择使用标题字段为订阅设置标题,以便对自己和其他管理员进行提醒。 + +例如,您可能会订阅 `https://lists.example.org/baddies.csv` 上的列表,并将该订阅的标题设置为某些反映该列表内容的描述,如“基础阻止列表(最为恶劣的实例)”或类似描述。 + +##### 订阅优先级 + +当你指定了多个域名权限订阅时,它们将按优先级顺序从最高优先级 (255) 到最低优先级 (0) 被获取和解析。 + +在优先级排名靠前的列表中发现的权限将覆盖在优先级排名靠后的列表中的权限。 + +有关优先级的更多信息,参见单独的[域名权限订阅](./domain_permission_subscriptions.md)文档。 + +##### 权限类型 + +你可以使用此下拉菜单选择为在订阅地址中发现的权限创建的条目类型,可以为阻止或允许。 + +##### 内容类型 + +您可以使用此下拉菜单选择订阅地址指向的列表的内容类型。 + +要订阅与 Mastodon 格式兼容的权限列表,可以选择 CSV,要使用纯文本域名列表,可以选择 plain,也可以选择 JSON,用于订阅以 JSON 格式导出的列表。 + +##### 基础认证(Basic Auth) + +勾选此复选框,可以为订阅列表提供基础认证用户名和/或密码凭证,这些凭证将在每次向订阅地址请求列表时一并发送。 + +##### 接管孤立权限条目 + +如果勾选此框,那么在以下情况下,任何现有的域名权限将由该订阅管理: + +1. 该权限条目没有关联的订阅 ID(即,它们不受任何域权限订阅管理)。 +2. 该权限条目与此订阅地址中包含的域名权限匹配。 + +有关孤立权限的更多信息,参见单独的[域名权限订阅](./domain_permission_subscriptions.md)文档。 + +##### 将此条目设为草稿 + +勾选此复选框后(该复选框默认勾选),通过此订阅创建的任何权限条目将以**草稿**类型创建,需要手动批准才能生效。 + +建议保留此复选框为已勾选状态,除非您完全信任订阅列表,以避免无意中阻止或允许您不想阻止或允许的域。 + +##### 测试订阅 + +要测试订阅是否可以被成功解析,首先创建订阅,然后在该订阅的详情视图中,点击“测试”按钮。 + +如果您的实例能够获取并解析订阅地址处的权限列表,则在点击“测试”后您将看到这些权限的列表。否则,您将看到一条错误信息。 + +![订阅详情视图的截图,箭头指向靠近底部的测试部分。](../public/admin-settings-federation-subscription-test.png) + ## 管理 实例管理设置。 @@ -167,3 +246,11 @@ GoToSocial 管理设置面板使用 [管理 API](https://docs.gotosocial.org/zh- 选择的 **联系人用户** 必须是实例上的活跃(未封禁)的管理员和/或站务。 如果你是在单用户实例上并将管理员权限授予你的主账户,你只需在此处填写自己的用户名即可;无需为此专门创建管理账户。 + +### 实例自定义 CSS + +自定义 CSS 允许您进一步调整通过浏览器访问的实例时的外观。 + +这些自定义 CSS 将应用于实例的所有页面。但用户主题和 CSS 仍优先于此处的自定义设置。 + +有关为您的实例编写自定义 CSS 的一些技巧,请参阅[自定义 CSS](../user_guide/custom_css.md)页面。 diff --git a/docs/locales/zh/admin/signups.md b/docs/locales/zh/admin/signups.md index 7b94a6910..0557bfb13 100644 --- a/docs/locales/zh/admin/signups.md +++ b/docs/locales/zh/admin/signups.md @@ -4,7 +4,7 @@ 注意,作为实例管理员,无论你是否愿意,你都需对在你的实例上发布的内容负责。如果你的实例用户在联合网上骚扰或烦扰他人,可能会导致你的实例名誉受损,并被其他人屏蔽。妥善管理一个社区需要付出努力。因此,你应仔细考虑是否愿意且有能力进行管理,及是否只接受朋友和你非常信任的人注册账户。 -!!! warning +!!! warning "警告" 为使注册流程正常运作,你的实例应[配置电子邮件发件服务](../configuration/smtp.md)。 如下所述,在注册流程中,会向你(作为管理员/站务)和申请人发送几封邮件,包括要求对方确认邮箱地址的邮件。 @@ -41,7 +41,7 @@ 如果你**拒绝**注册,可以选择通知申请人注册被拒,你可以通过勾选“发送邮件”复选框来实现。这将向申请人发送一封简短邮件,告知其被拒。如果需要,还可以添加自定义消息,该消息将添加在邮件底部。你还可以添加仅供其他管理员查看的私人备注。 -!!! warning +!!! warning "警告" 你可能希望等申请人确认他们的电子邮件地址后再批准注册,以防申请时输入错误或提供不是他们的电子邮件地址。如果他们不能确认电子邮件地址,将无法登录和使用账户。 ## 注册限制 diff --git a/docs/locales/zh/admin/spam.md b/docs/locales/zh/admin/spam.md index 7af7062b3..1830be18c 100644 --- a/docs/locales/zh/admin/spam.md +++ b/docs/locales/zh/admin/spam.md @@ -6,12 +6,12 @@ 被认为是骚扰信息的消息将不会存储在你的本站实例上,也不会生成通知。 -!!! warning +!!! warning "警告" 骚扰信息过滤器必然是不完美的工具,因为它们可能会误判一些合法的信息为垃圾,或者确实未能抓住一些*确实*是垃圾的信息。 启用 `instance-federation-spam-filter` 应被视为当联合网络遭遇骚扰信息攻击时的一种“加固”选项。在正常情况下,你可能希望将其关闭,以避免意外过滤掉合法信息。 -!!! tip +!!! tip "提示" 如果你想检查骚扰信息过滤器捕获了哪些内容(如果有的话),可以在日志中搜索 `looked like spam`。 如果你[将 GoToSocial 作为 systemd 服务运行](../getting_started/installation/metal.md#optional-enable-the-systemd-service),可以使用以下命令: diff --git a/docs/locales/zh/advanced/caching/index.md b/docs/locales/zh/advanced/caching/index.md index 85b2292b5..973512367 100644 --- a/docs/locales/zh/advanced/caching/index.md +++ b/docs/locales/zh/advanced/caching/index.md @@ -2,7 +2,7 @@ 本节涵盖了多种缓存技术,这些技术可以提高 GoToSocial 在高流量情况下的稳定性,并减轻 GoToSocial 实例的一部分工作负担。 -!!! note +!!! note "注意" 这些指南仅在你运行[反向代理](../../getting_started/reverse_proxy/index.md)时才有意义。 ## 指南 diff --git a/docs/locales/zh/advanced/certificates.md b/docs/locales/zh/advanced/certificates.md index 2b2d0fa0c..a6b956b51 100644 --- a/docs/locales/zh/advanced/certificates.md +++ b/docs/locales/zh/advanced/certificates.md @@ -66,7 +66,7 @@ tls-certificate-key: "/path/to/private.key" 这将禁用通过 Lets Encrypt 内置的证书配置,并指示 GoToSocial 在磁盘上找到证书。 -!!! tip +!!! tip "提示" 在续订证书后应重启 GoToSocial。它在这种情况下不会自动监测证书的更换。 ### 使用反向代理 @@ -93,7 +93,7 @@ tls-certificate-key: "" * [Traefik](https://doc.traefik.io/traefik/https/tls/) * [Caddy](https://caddyserver.com/docs/caddyfile/directives/tls) -!!! tip +!!! tip "提示" 在你的反向代理中配置 TLS 时,请确保你配置了一组较现代的兼容版本和加密套件。可以使用 [Mozilla SSL Configuration Generator](https://ssl-config.mozilla.org/) 的“中级”配置。 检查你的反向代理文档,以了解在证书更改后是否需要重新加载或重启它。并非所有的反向代理都会自动检测到这一点。 diff --git a/docs/locales/zh/advanced/healthchecks.md b/docs/locales/zh/advanced/healthchecks.md index e3063842a..98237644a 100644 --- a/docs/locales/zh/advanced/healthchecks.md +++ b/docs/locales/zh/advanced/healthchecks.md @@ -23,12 +23,12 @@ healthcheck: 上述健康检查将在 30 秒后开始,每两分钟检查一次服务是否可用,通过对 `/readyz` 进行 HEAD 请求。如果检查连续失败五次,服务将被标记为不健康。你可以在使用的编排系统中利用此功能强制重启容器。 -!!! warning +!!! warning "警告" 在慢速硬件上进行数据库迁移时,迁移可能会超过上述健康检查所允许的 10 分钟。 在这样的系统上,你可能需要增加健康检查的间隔或重试次数,以确保不会在迁移中途停止 GoToSocial(这会很糟糕!)。 -!!! tip +!!! tip "提示" 尽管健康检查端点不透露任何敏感信息,并且只运行非常简单的查询,你可能希望避免将它们暴露给外部世界。你可以在 nginx 中通过在 `server` 段中添加以下代码片段来实现: ```nginx diff --git a/docs/locales/zh/advanced/host-account-domain.md b/docs/locales/zh/advanced/host-account-domain.md index 5b758a99c..bd25abd3c 100644 --- a/docs/locales/zh/advanced/host-account-domain.md +++ b/docs/locales/zh/advanced/host-account-domain.md @@ -2,7 +2,7 @@ 本指南解释了如何使用 `@me@example.org` 这样的用户名,但将 GoToSocial 实例本身运行在例如 `social.example.org` 这样的子域名的方法。这种部署布局的配置**必须**在第一次启动 GoToSocial 前完成。 -!!! danger +!!! danger "警告" 一旦与他人联合后就无法更改域名布局。服务器会因此产生混淆,而你需要说服每个与你联合的实例管理员修改其数据库来解决问题。同时,你还需要在本地重新生成数据库,创建一个新的实例账户和加密密钥对。 ## 背景 @@ -49,7 +49,7 @@ host: social.example.org account-domain: example.org ``` -!!! info +!!! info "附注" `host` 必须始终是运行 GoToSocial 实例的 DNS 名称。它不影响 GoToSocial 实例绑定的 IP 地址。该地址由 `bind-address` 控制。 ## 反向代理 @@ -62,7 +62,7 @@ account-domain: example.org * `/.well-known/host-meta` * `/.well-known/nodeinfo` -!!! tip +!!! tip "提示" 不要将 API 端点 `/api/...` 的请求从账户域代理或重定向到主机域。这会混淆某些客户端用来检测分域部署的启发式方法,导致登录流程中断及其他异常行为。 ### nginx diff --git a/docs/locales/zh/advanced/security/index.md b/docs/locales/zh/advanced/security/index.md index bdd80b912..aaee26413 100644 --- a/docs/locales/zh/advanced/security/index.md +++ b/docs/locales/zh/advanced/security/index.md @@ -2,7 +2,7 @@ 这些指南涵盖如何提高你的 GoToSocial 部署的安全状况。它们不涉及调整 GoToSocial 的设置,而是指出一些你可以做的额外措施,以更好地保护你的实例。 -!!! note +!!! note "注意" 这些指南中的任何内容旨在增强你的 GoToSocial 部署的安全性;它们不能替代良好的安全实践,比如保持你的系统定期得到修补和更新。 ## 指南 diff --git a/docs/locales/zh/advanced/sqlite-networked-storage.md b/docs/locales/zh/advanced/sqlite-networked-storage.md index a319aa20a..e57352509 100644 --- a/docs/locales/zh/advanced/sqlite-networked-storage.md +++ b/docs/locales/zh/advanced/sqlite-networked-storage.md @@ -2,7 +2,7 @@ SQLite 的运行模式假定数据库和使用它的进程或应用程序位于同一主机上。在运行 WAL 模式(GoToSocial 的默认模式)时,它依赖于进程之间的共享内存来确保数据库完整性。 -!!! quote +!!! quote "参考" 所有使用数据库的进程必须在同一台主机计算机上;WAL 不能在网络文件系统上工作。这是因为 WAL 需要所有进程共享少量内存,而在不同主机上的进程显然不能相互共享内存。 — SQLite.org [写前日志](https://www.sqlite.org/wal.html) diff --git a/docs/locales/zh/api/authentication.md b/docs/locales/zh/api/authentication.md index 798c52b4c..2590f4fe4 100644 --- a/docs/locales/zh/api/authentication.md +++ b/docs/locales/zh/api/authentication.md @@ -25,7 +25,7 @@ curl \ - `write` - `admin` -!!! warning +!!! warning "警告" GoToSocial 目前不支持范围授权令牌,因此在此过程中获得的任何令牌都可以代表你执行所有操作,包括如果你的账户具有管理员权限时的管理员操作。然而,始终以最低权限授予你的应用是一个好习惯。例如,如果你的应用不会发布贴文,请使用 scope=read。 本着这种精神,上述示例使用了`read`,这意味着当未来支持范围令牌时,应用将仅限于执行`read`操作。 @@ -44,7 +44,7 @@ curl \ } ``` -!!! tip +!!! tip "提示" 确保将 `client_id` 和 `client_secret` 的值保存到某个位置,以便在需要时参考。 ## 授权你的应用代表你操作 @@ -57,7 +57,7 @@ curl \ https://example.org/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=read ``` -!!! tip +!!! tip "提示" 如果你在注册应用时使用了不同的范围,在上面的 URL 中将 `scope=read` 替换为你注册时使用的加号分隔的范围列表。例如,如果你注册你的应用时使用了 `scopes` 值 `read write`,那么你应该将上面的 `scope=read` 改为 `scope=read+write`。 将 URL 粘贴到浏览器后,你会被引导到实例的登录表单,提示你输入邮箱地址和密码以将应用连接到你的账户。 diff --git a/docs/locales/zh/api/ratelimiting.md b/docs/locales/zh/api/ratelimiting.md index a9533fa01..71ba542e5 100644 --- a/docs/locales/zh/api/ratelimiting.md +++ b/docs/locales/zh/api/ratelimiting.md @@ -24,11 +24,11 @@ ### 我总是超出速率限制!为什么? -如果你发现自己的速率限制在正常使用时经常被超出(对于你自己和其他请求者也是如此),这可能是因为 GoToSocial 无法通过 IP 地址区分客户端。你可以通过查看实例的日志来调查这个问题。如果(几乎)所有记录的 IP 地址似乎都是相同的 IP 地址(类似于 `172.x.x.x`),那么速率限制将导致问题。 +如果你发现自己的速率限制在正常使用时经常被超出(对于你自己和其他请求者也是如此),这可能是因为 GoToSocial 无法通过 IP 地址区分客户端。你可以通过查看实例的日志来调查这个问题。如果(几乎)所有记录的客户端 IP 地址似乎都是相同的 IP 地址(类似于 `172.x.x.x`),那么速率限制将导致问题。 这种情况通常发生在你的服务器运行在 NAT(端口转发)中,或者在没有正确配置的 HTTP 代理之后,导致你的实例将所有传入 IP 地址视为相同的地址:即你的反向代理或网关的 IP 地址。这意味着所有传入请求*共享同一个速率限制*,而不是按 IP 正确分开。 -如果你正在使用 HTTP 代理,那么很可能你的 `trusted-proxies` 未正确配置。如果是这种情况,尝试将反向代理的 IP 地址添加到 `trusted-proxies` 列表中,并重启你的实例。 +如果你使用了 HTTP 代理,那么你的 `trusted-proxies` 配置可能不正确。详情请参阅 [可信代理](../configuration/trusted_proxies.md) 文档以了解如何解决此问题。 如果没有使用 HTTP 代理,那么很可能是由 NAT 引起的。在这种情况下,你应该完全禁用速率限制。 diff --git a/docs/locales/zh/api/swagger.md b/docs/locales/zh/api/swagger.md index ad069d4d7..7fa3190d5 100644 --- a/docs/locales/zh/api/swagger.md +++ b/docs/locales/zh/api/swagger.md @@ -6,7 +6,7 @@ GoToSocial 使用 [go-swagger](https://github.com/go-swagger/go-swagger) 从代 大多数 GoToSocial API 端点需要用户级别的 OAuth 令牌。有关如何使用 OAuth 令牌进行 API 认证的指南,请参阅[认证文档](./authentication.md)。 -!!! tip +!!! tip "提示" 如果你想更多地使用该规范,还可以直接查看 [swagger.yaml](./swagger.yaml),然后将其粘贴到 [Swagger Editor](https://editor.swagger.io/) 等工具中。这样你可以尝试自动生成不同语言的 GoToSocial API 客户端(不支持,但可以尝试),或者将文档转换为 JSON 或 OpenAPI v3 规范等。更多信息请参见[这里](https://swagger.io/tools/open-source/getting-started/)。 !!! info "注意事项:上传文件" diff --git a/docs/locales/zh/api/swagger.yaml b/docs/locales/zh/api/swagger.yaml index 070a9448c..3ac20cbfa 100644 --- a/docs/locales/zh/api/swagger.yaml +++ b/docs/locales/zh/api/swagger.yaml @@ -81,10 +81,20 @@ definitions: x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model NodeInfoSoftware: properties: + homepage: + description: 该软件的主页,此字段在版本 2.0 中被省略。 + example: https://docs.gotosocial.org/zh-cn/ + type: string + x-go-name: Homepage name: example: gotosocial type: string x-go-name: Name + repository: + description: 该软件的存储库,此字段在版本 2.0 中被省略。 + example: https://codeberg.org/superseriousbusiness/gotosocial + type: string + x-go-name: Repository version: example: 0.1.2 1234567 type: string @@ -95,6 +105,10 @@ definitions: x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model NodeInfoUsage: properties: + localComments: + format: int64 + type: integer + x-go-name: LocalComments localPosts: format: int64 type: integer @@ -107,6 +121,14 @@ definitions: x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model NodeInfoUsers: properties: + activeHalfYear: + format: int64 + type: integer + x-go-name: ActiveHalfYear + activeMonth: + format: int64 + type: integer + x-go-name: ActiveMonth total: format: int64 type: integer @@ -193,6 +215,10 @@ definitions: description: TimelineMarker 包含有关用户在特定时间线上的阅读进度的信息。 type: object x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + WebPushNotificationPolicy: + description: WebPushNotificationPolicy 包含可以生成通知的帐户集合。 + type: string + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model account: description: Account 是一个 Fediverse 账户的抽象模型。被抽象的账户可以是本站账户,也可以是外站账户。 properties: @@ -281,6 +307,10 @@ definitions: format: int64 type: integer x-go-name: FollowingCount + group: + description: 该账户被标记为 Group 类型的行为体。 + type: boolean + x-go-name: Group header: description: 该账户的资料卡横幅背景图片的网络地址。 example: https://example.org/media/some_user/header/original/header.jpeg @@ -1131,6 +1161,101 @@ definitions: type: object x-go-name: DomainPermission x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + domainPermissionSubscription: + properties: + adopt_orphans: + description: '若为 true,则此域名权限订阅将“接管”实例上已存在的、符合以下条件的域名权限: 1)它们没有关联的订阅 ID(即,它们是“孤立”的), 2)它们存在于订阅列表中。这些孤立的域名权限条目将被关联到此订阅的订阅 ID,并由此订阅管理。' + example: false + type: boolean + x-go-name: AdoptOrphans + as_draft: + description: 若为 true,则此域名权限订阅将创建为草稿,须由管理员批准后才能生效。若为 false,此域名权限订阅将立即生效。 + example: true + type: boolean + x-go-name: AsDraft + content_type: + description: 解析权限列表时采用的 MIME 内容类型。 + example: text/csv + type: string + x-go-name: ContentType + count: + description: 上次(成功)获取时在订阅地址上发现的域名权限条目数量。 + example: 53 + format: uint64 + readOnly: true + type: integer + x-go-name: Count + created_at: + description: 订阅创建的时间(ISO 8601 Datetime)。 + example: "2021-07-30T09:20:25+00:00" + type: string + x-go-name: CreatedAt + created_by: + description: 创建此订阅的帐户的 ID。 + example: 01FBW21XJA09XYX51KV5JVBW0F + readOnly: true + type: string + x-go-name: CreatedBy + error: + description: 如果最近的获取尝试失败,此字段将包含与获取尝试相关的错误消息。 + example: Oopsie doopsie, we made a fucky wucky. + readOnly: true + type: string + x-go-name: Error + fetch_password: + description: (可选)更新订阅时进行基本身份验证(Basic Auth)的密码。 + example: admin123 + type: string + x-go-name: FetchPassword + fetch_username: + description: (可选)更新订阅时进行基本身份验证(Basic Auth)的用户名。 + example: admin123 + type: string + x-go-name: FetchUsername + fetched_at: + description: 上次更新订阅(不论是否成功)的时间(ISO 8601 Datetime)。 + example: "2021-07-30T09:20:25+00:00" + readOnly: true + type: string + x-go-name: FetchedAt + id: + description: 域名权限订阅的 ID。 + example: 01FBW21XJA09XYX51KV5JVBW0F + readOnly: true + type: string + x-go-name: ID + permission_type: + description: 域名权限订阅的类型(允许, 阻止)。 + example: block + type: string + x-go-name: PermissionType + priority: + description: 域名权限订阅的优先级(0-255, 数字越大, 优先级越高)。 + example: 100 + format: uint8 + type: integer + x-go-name: Priority + successfully_fetched_at: + description: 上次成功更新订阅的时间(ISO 8601 Datetime)。 + example: "2021-07-30T09:20:25+00:00" + readOnly: true + type: string + x-go-name: SuccessfullyFetchedAt + title: + description: 域名权限订阅的标题。由管理员在创建或更新时设置。 + example: really cool list of neato pals + type: string + x-go-name: Title + uri: + description: 域名权限订阅的 URI, 用于从中获取域名权限条目列表。 + example: https://www.example.org/blocklists/list1.csv + type: string + x-go-name: URI + title: DomainPermissionSubscription + description: DomainPermissionSubscription (域名权限订阅)表示一个可以自动更新的域名权限列表订阅(类型可以为允许或阻止) + type: object + x-go-name: DomainPermissionSubscription + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model emoji: properties: category: @@ -1580,6 +1705,10 @@ definitions: $ref: '#/definitions/instanceV1Configuration' contact_account: $ref: '#/definitions/account' + custom_css: + description: 此实例的自定义 CSS。 + type: string + x-go-name: CustomCSS debug: description: 此实例是否在 DEBUG 模式下运行。如果为 false,则省略。 type: boolean @@ -1761,6 +1890,10 @@ definitions: $ref: '#/definitions/instanceV2Configuration' contact: $ref: '#/definitions/instanceV2Contact' + custom_css: + description: 此实例的自定义 CSS。 + type: string + x-go-name: CustomCSS debug: description: 此实例是否在 DEBUG 模式下运行。如果为 false,则省略。 type: boolean @@ -1856,6 +1989,8 @@ definitions: $ref: '#/definitions/instanceV2ConfigurationTranslation' urls: $ref: '#/definitions/instanceV2URLs' + vapid: + $ref: '#/definitions/instanceV2ConfigurationVAPID' title: InstanceV2Configuration description: 此实例的配置值和限制。 type: object @@ -1874,6 +2009,16 @@ definitions: type: object x-go-name: InstanceV2ConfigurationTranslation x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + instanceV2ConfigurationVAPID: + properties: + public_key: + description: The instance's VAPID public key, Base64-encoded. + type: string + x-go-name: PublicKey + title: InstanceV2ConfigurationVAPID 存储实例的 VAPID 配置信息。 + type: object + x-go-name: InstanceV2ConfigurationVAPID + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model instanceV2Contact: properties: account: @@ -2324,6 +2469,10 @@ definitions: format: int64 type: integer x-go-name: FollowingCount + group: + description: 该账户被标记为 Group 类型的行为体。 + type: boolean + x-go-name: Group header: description: 账户资料卡横幅背景图的 Web 地址。 example: https://example.org/media/some_user/header/original/header.jpeg @@ -2714,6 +2863,11 @@ definitions: example: "2021-07-30T09:20:25+00:00" type: string x-go-name: CreatedAt + edited_at: + description: 此贴文上次被编辑的时间 (ISO 8601 Datetime)。 + example: "2021-07-30T09:20:25+00:00" + type: string + x-go-name: EditedAt emojis: description: 此贴文内容中使用的自定义表情符号。 items: @@ -2908,6 +3062,11 @@ definitions: example: "2021-07-30T09:20:25+00:00" type: string x-go-name: CreatedAt + edited_at: + description: 此贴文上次被编辑的时间 (ISO 8601 Datetime)。 + example: "2021-07-30T09:20:25+00:00" + type: string + x-go-name: EditedAt emojis: description: 渲染此贴文时使用的自定义表情符号。 items: @@ -3296,6 +3455,141 @@ definitions: type: object x-go-name: User x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + webPushNotification: + description: |- + WebPushNotification 表示 Web 推送服务器传递给客户端的通知摘要。 + 它不包含完整的通知,仅包含通知 ID 和一些预览信息。 + 它并不直接用于客户端 API,而是包含在 API 文档中,用于解码 Web 推送通知。 + properties: + access_token: + description: |- + AccessToken 是与 Web 推送订阅关联的访问令牌。 + 尚不清楚为何要发送此令牌,因为客户端理应已知晓,但 Feditext 确实使用了它。 + type: string + x-go-name: AccessToken + body: + description: |- + Body 是通知正文的预览, + 例如状态的内容警告或文本的第一行, + 或帐户的简介的第一行。 + type: string + x-go-name: Body + icon: + description: |- + Icon 是通知中显示的图像的 URL, + 通常是帐户的头像。 + type: string + x-go-name: Icon + notification_id: + description: NotificationID 是所引用的通知的 Notification.ID。 + type: string + x-go-name: NotificationID + notification_type: + description: NotificationType 是所引用的通知的 Notification.Type。 + type: string + x-go-name: NotificationType + preferred_locale: + description: PreferredLocale 是接收通知的用户的语言标签(BCP 47 标签)。 + type: string + x-go-name: PreferredLocale + title: + description: |- + Title 是通知的标题, + 通常是用户执行的动作的描述。 + type: string + x-go-name: Title + title: WebPushNotification + type: object + x-go-name: WebPushNotification + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + webPushSubscription: + properties: + alerts: + $ref: '#/definitions/webPushSubscriptionAlerts' + endpoint: + description: 通知将被推送到的端点。 + type: string + x-go-name: Endpoint + id: + description: 数据库中推送订阅的 ID。 + type: string + x-go-name: ID + policy: + $ref: '#/definitions/WebPushNotificationPolicy' + server_key: + description: 此实例的 VAPID 公钥。 + type: string + x-go-name: ServerKey + standard: + description: |- + 是否使用 RFC 或预 RFC Web 推送标准。 + 对于 GotoSocial,这将总是为真。 + type: boolean + x-go-name: Standard + title: WebPushSubscription + description: WebPushSubscription 表示对 Web 推送服务器的订阅。 + type: object + x-go-name: WebPushSubscription + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + webPushSubscriptionAlerts: + properties: + admin.report: + description: 是否在收到新的举报时接收推送通知? + type: boolean + x-go-name: AdminReport + admin.sign_up: + description: 是否在有新用户注册时接收推送通知? + type: boolean + x-go-name: AdminSignup + favourite: + description: 是否在某条贴文被其他人点赞时接收推送通知? + type: boolean + x-go-name: Favourite + follow: + description: 是否在有人关注你时接收推送通知? + type: boolean + x-go-name: Follow + follow_request: + description: 是否在有人向你发出关注请求时接收推送通知? + type: boolean + x-go-name: FollowRequest + mention: + description: 是否在有人在贴文中提及你时接收推送通知? + type: boolean + x-go-name: Mention + pending.favourite: + description: 是否在有点赞待处理时接收推送通知? + type: boolean + x-go-name: PendingFavourite + pending.reblog: + description: 是否在有转发待处理时接收推送通知? + type: boolean + x-go-name: PendingReblog + pending.reply: + description: 是否在有回复待处理时接收推送通知? + type: boolean + x-go-name: PendingReply + poll: + description: 是否在你参与或创建的投票结束时接收推送通知? + type: boolean + x-go-name: Poll + reblog: + description: 是否在你创建的贴文被别人转发时接收推送通知? + type: boolean + x-go-name: Reblog + status: + description: 是否在你订阅的某个账户发帖时接收推送通知? + type: boolean + x-go-name: Status + update: + description: 是否在你互动过的贴文被编辑时接收推送通知? + type: boolean + x-go-name: Update + title: WebPushSubscriptionAlerts + description: WebPushSubscriptionAlerts 代表此 Web 推送订阅将接收的具体事件。 + type: object + x-go-name: WebPushSubscriptionAlerts + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model wellKnownResponse: properties: aliases: @@ -3328,7 +3622,7 @@ info: name: AGPL3 url: https://www.gnu.org/licenses/agpl-3.0.zh-cn.html title: GoToSocial Swagger 文档 - version: 0.17.2-SNAPSHOT-8a93300a + version: 0.18.0-SNAPSHOT-e10de846 paths: /.well-known/host-meta: get: @@ -3660,6 +3954,41 @@ paths: description: 屏蔽具有给定 ID 的帐户。 tags: - accounts + /api/v1/accounts/{id}/featured_tags: + get: + operationId: accountsFeaturedTags + parameters: + - description: 目标账户的 ID。 + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: "" + schema: + items: + type: object + type: array + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - read:accounts + summary: 获取账户精选话题标签 + description: 以数组的形式获取目标帐户的精选话题标签。此端点目前尚未完全实现:它将始终返回一个空数组。 + tags: + - accounts /api/v1/accounts/{id}/follow: post: consumes: @@ -5850,7 +6179,7 @@ paths: required: true type: string - default: false - description: 删除此域名权限草案时,为目标域名创建一个域名排除条目,以确保之后不会为此域名创建草案。 + description: 删除此域名权限草案时,为目标域名创建一个域名例外条目,以确保之后不会为此域名创建草案。 in: formData name: exclude_target type: boolean @@ -5882,14 +6211,14 @@ paths: /api/v1/admin/domain_permission_excludes: get: description: |- - 返回按时间倒序排序(新创建的条目优先),并带有连续 ID 的域名权限排除条目(ID 值越大,排除条目越新)。可以通过返回的 Link 标头解析下一页与上一页查询。 + 返回按时间倒序排序(新创建的条目优先),并带有连续 ID 的域名权限例外条目(ID 值越大,例外条目越新)。可以通过返回的 Link 标头解析下一页与上一页查询。 示例: ``` ; rel="next", ; rel="prev" ``` operationId: domainPermissionExcludesGet parameters: - - description: 仅返回针对给定域名的排除条目。 + - description: 仅返回针对给定域名的例外条目。 in: query name: domain type: string @@ -5916,7 +6245,7 @@ paths: - application/json responses: "200": - description: 域名权限排除条目。 + description: 域名权限例外条目。 headers: Link: description: 下一查询与上一查询的链接。 @@ -5940,7 +6269,7 @@ paths: security: - OAuth2 Bearer: - admin - summary: 查看域名权限排除条目。 + summary: 查看域名权限例外条目。 tags: - admin post: @@ -5948,15 +6277,15 @@ paths: - multipart/form-data - application/json description: |- - 被排除的域名(及其子域名)在导入或订阅域名权限列表时不会被自动屏蔽或放行。 - 您仍然可以为被排除的域名手动创建域名屏蔽条目或域名放行条目,被排除之后,与该域名关联的任何的已有或新创建的域名屏蔽条目或域名放行条目都将被继续执行。 + 被设为例外的域名(及其子域名)在导入或订阅域名权限列表时不会被自动阻止或允许。 + 您仍然可以为被设为例外的域名手动创建域名阻止条目或域名允许条目,被设为例外之后,与该域名关联的任何的已有或新创建的域名阻止条目或域名允许条目都将被继续执行。 operationId: domainPermissionExcludeCreate parameters: - - description: 要创建权限排除的域名。 + - description: 要创建的权限例外条目的目标域名。 in: formData name: domain type: string - - description: 对该域名排除条目的私密评论。 + - description: 对该域名例外条目的私密评论。 in: formData name: private_comment type: string @@ -5964,7 +6293,7 @@ paths: - application/json responses: "200": - description: 新创建的域名排除条目。 + description: 新创建的域名例外条目。 schema: $ref: '#/definitions/domainPermission' "400": @@ -5982,14 +6311,14 @@ paths: security: - OAuth2 Bearer: - admin - summary: 使用给定参数创建一个域名权限排除条目。 + summary: 使用给定参数创建一个域名权限例外条目。 tags: - admin /api/v1/admin/domain_permission_excludes/{id}: delete: operationId: domainPermissionExcludeDelete parameters: - - description: 该域名权限排除条目的 ID。 + - description: 该域名权限例外条目的 ID。 in: path name: id required: true @@ -5998,7 +6327,7 @@ paths: - application/json responses: "200": - description: 被移除的域名权限排除条目。 + description: 被移除的域名权限例外条目。 schema: $ref: '#/definitions/domainPermission' "400": @@ -6016,13 +6345,13 @@ paths: security: - OAuth2 Bearer: - admin - summary: 移除一个域名权限排除条目。 + summary: 移除一个域名权限例外条目。 tags: - admin get: operationId: domainPermissionExcludeGet parameters: - - description: 域名权限排除条目的 ID。 + - description: 域名权限例外条目的 ID。 in: path name: id required: true @@ -6031,7 +6360,7 @@ paths: - application/json responses: "200": - description: 域名权限排除条目。 + description: 域名权限例外条目。 schema: $ref: '#/definitions/domainPermission' "401": @@ -6047,7 +6376,378 @@ paths: security: - OAuth2 Bearer: - admin - summary: 获取具有给定 ID 的域名权限排除。 + summary: 获取具有给定 ID 的域名权限例外条目。 + tags: + - admin + /api/v1/admin/domain_permission_subscriptions: + get: + description: |- + 订阅将按时间倒序返回(最新的订阅在前),并带有连续的 ID (值越大代表订阅越新)。 + 可以通过返回的 Link 标头解析下一页与上一页查询。 + 示例: + ``` + ; rel="next", ; rel="prev" + ```` + operationId: domainPermissionSubscriptionsGet + parameters: + - description: 筛选类型为“阻止”或“允许”的订阅。 + in: query + name: permission_type + type: string + - description: 仅返回 ID 小于给定的最大 ID 的条目(用于向下分页)。具有对应 ID 的条目不会包含在结果中。 + in: query + name: max_id + type: string + - description: 仅返回 ID 大于给定的最小 ID 的条目(用于向上分页)。具有对应 ID 的条目不会包含在结果中。 + in: query + name: since_id + type: string + - description: 仅返回 ID 比指定最小 ID 相邻且*更新* 的条目(用于向上分页)。具有对应 ID 的条目不会包含在结果中。 + in: query + name: min_id + type: string + - default: 20 + description: 要返回的条目数量。 + in: query + maximum: 100 + minimum: 1 + name: limit + type: integer + produces: + - application/json + responses: + "200": + description: 域名权限订阅列表。 + headers: + Link: + description: 下一查询与上一查询的链接 + type: string + schema: + items: + $ref: '#/definitions/domainPermissionSubscription' + type: array + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 查看域名权限订阅列表 + tags: + - admin + post: + consumes: + - multipart/form-data + - application/json + operationId: domainPermissionSubscriptionCreate + parameters: + - default: 0 + description: 此订阅相对于其他同类型的订阅的优先级。取值范围为 0-255 (数值越高,优先级越高)。优先级较高的订阅将会覆盖优先级较低的订阅生成的权限。当两个订阅的`priority`(优先级)值相同时,优先级无法确定,因此建议始终手动设置此值。 + in: formData + maximum: 255 + minimum: 0 + name: priority + type: number + - description: 此订阅的标题(可选) + in: formData + name: title + type: string + - description: 解析订阅列表/订阅目标文件时要创建的域名权限类型。需要为 "allow" 或 "block"。 + in: formData + name: permission_type + required: true + type: string + - default: true + description: 如果为 true,此订阅产生的域名权限条目将以草稿形式创建,须管理员批准后才能生效。如果为 false,此订阅下的域名权限条目将立即生效。默认为 true。 + in: formData + name: as_draft + type: boolean + - default: false + description: '若为 true,则此域名权限订阅将“接管”实例上已存在的、符合以下条件的域名权限: 1)它们没有关联的订阅 ID(即,它们是“孤立”的), 2)它们存在于订阅列表中。这些孤立的域名权限条目将被关联到此订阅的订阅 ID,并由此订阅管理。' + in: formData + name: adopt_orphans + type: boolean + - description: 此订阅要获取的权限列表的 URI。 + in: formData + name: uri + required: true + type: string + - description: 此订阅要使用的 MIME 内容类型。可以为 "text/plain"、"text/csv" 或 "application/json"。 + in: formData + name: content_type + required: true + type: string + - description: 可选的基本身份验证(Basic Auth)用户名,用于获取指定 URI。如果设置,则在获取时会与 `fetch_password` 一起传输。 + in: formData + name: fetch_username + type: string + - description: 可选的基本身份验证(Basic Auth)密码,用于获取指定 URI。如果设置,则在获取时会与 `fetch_username` 一起传输。 + in: formData + name: fetch_password + type: string + produces: + - application/json + responses: + "200": + description: 新创建的域名权限订阅。 + schema: + $ref: '#/definitions/domainPermissionSubscription' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 创建域名权限订阅 + description: 使用给定参数创建一个新的域名权限订阅。 + tags: + - admin + /api/v1/admin/domain_permission_subscriptions/${id}: + patch: + consumes: + - multipart/form-data + - application/json + operationId: domainPermissionSubscriptionUpdate + parameters: + - description: 域名权限订阅的 ID。 + in: path + name: id + required: true + type: string + - description: 此订阅相对于其他同类型的订阅的优先级。取值范围为 0-255 (数值越高,优先级越高)。优先级较高的订阅将会覆盖优先级较低的订阅生成的权限。当两个订阅的`priority`(优先级)值相同时,优先级无法确定,因此建议始终手动设置此值。 + in: formData + maximum: 255 + minimum: 0 + name: priority + type: number + - description: 此订阅的标题(可选)。 + in: formData + name: title + type: string + - description: 此订阅要获取的域名权限列表的 URI。 + in: formData + name: uri + type: string + - default: true + description: 如果为 true,此订阅产生的域名权限条目将以草稿形式创建,须管理员批准后才能生效。如果为 false,此订阅下的域名权限条目将立即生效。默认为 true。 + in: formData + name: as_draft + type: boolean + - default: false + description: '若为 true,则此域名权限订阅将“接管”实例上已存在的、符合以下条件的域名权限: 1)它们没有关联的订阅 ID(即,它们是“孤立”的), 2)它们存在于订阅列表中。这些孤立的域名权限条目将被关联到此订阅的订阅 ID,并由此订阅管理。' + in: formData + name: adopt_orphans + type: boolean + - description: 此订阅要使用的 MIME 内容类型。可以为 "text/plain"、"text/csv" 或 "application/json"。 + in: formData + name: content_type + type: string + - description: 可选的基本身份验证(Basic Auth)用户名,用于获取指定 URI。如果设置,则在获取时会与 `fetch_password` 一起传输。 + in: formData + name: fetch_username + type: string + - description: 可选的基本身份验证(Basic Auth)密码,用于获取指定 URI。如果设置,则在获取时会与 `fetch_username` 一起传输。 + in: formData + name: fetch_password + type: string + produces: + - application/json + responses: + "200": + description: 更新后的域名权限订阅。 + schema: + $ref: '#/definitions/domainPermissionSubscription' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 更新域名权限订阅 + description: 使用给定参数更新一个域名权限订阅。 + tags: + - admin + /api/v1/admin/domain_permission_subscriptions/{id}: + get: + operationId: domainPermissionSubscriptionGet + parameters: + - description: 域名权限订阅的 ID。 + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 要获取的域名权限订阅。 + schema: + $ref: '#/definitions/domainPermissionSubscription' + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 获取指定域名权限订阅 + description: 获取具有给定 ID 的单个域名权限订阅。 + tags: + - admin + /api/v1/admin/domain_permission_subscriptions/{id}/remove: + post: + consumes: + - multipart/form-data + - application/json + operationId: domainPermissionSubscriptionRemove + parameters: + - description: 域名权限订阅的 ID。 + in: path + name: id + required: true + type: string + - default: true + description: |- + 移除域名权限订阅时,也应移除此订阅的子条目,即由该订阅管理的域名权限。如果为否,则子条目将成为孤立条目,但不会被移除。 + 请注意,已被移除的权限条目可能稍后会被另一个优先级低于已移除订阅的域名权限订阅重新创建。同样地,孤立子项也可能稍后被另一个订阅接收。 + in: formData + name: remove_children + type: boolean + produces: + - application/json + responses: + "200": + description: 被移除的域名权限订阅。 + schema: + $ref: '#/definitions/domainPermissionSubscription' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 删除单个域名权限订阅 + tags: + - admin + /api/v1/admin/domain_permission_subscriptions/{id}/test: + post: + description: |- + 让你的实例获取并解析域名权限订阅列表,来测试单个域名权限订阅,*无需实际创建权限*。 + + 响应体将为一个该订阅*将会*创建的域权限列表,或是一条错误消息。 + + 这在你需要检查你的实例是否能够实际获取和解析列表的情况下非常有用。 + operationId: domainPermissionSubscriptionTest + parameters: + - description: 该域名权限订阅草稿的 ID。 + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 一个域名权限条目的数组,或一个说明为何无法获取该列表的,形如 `{"error":"[错误信息]"}` 的错误消息。 + schema: + items: + $ref: '#/definitions/domain' + type: array + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 测试单个域名权限订阅 + tags: + - admin + /api/v1/admin/domain_permission_subscriptions/preview: + get: + description: 查看给定权限类型的全部域名权限订阅,按优先级顺序排列(从高到低)。此视图可显示实际被获取和创建的域名权限订阅的顺序。 + operationId: domainPermissionSubscriptionsPreviewGet + parameters: + - description: 筛选类型为 "block" 或 "allow" 的订阅。 + in: query + name: permission_type + required: true + type: string + produces: + - application/json + responses: + "200": + description: 域名权限订阅列表。 + schema: + items: + $ref: '#/definitions/domainPermissionSubscription' + type: array + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止访问 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - admin + summary: 预览全部域名权限订阅 tags: - admin /api/v1/admin/email/test: @@ -6762,6 +7462,34 @@ paths: description: 查看具有给定 ID 的实例规则。 tags: - admin + /api/v1/announcements: + get: + operationId: announcementsGet + produces: + - application/json + responses: + "200": + description: "" + schema: + items: + type: object + maxItems: 0 + type: array + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - read:announcements + summary: 获取公告 + description: '以数组形式获取当前生效的公告。此端点目前尚未完全实现:它将无条件返回一个空数组。' + tags: + - announcements /api/v1/apps: post: consumes: @@ -7345,14 +8073,14 @@ paths: 此过滤规则要应用的上下文。 示例: home, public - enum: - - home - - notifications - - public - - thread - - account in: formData items: + enum: + - home + - notifications + - public + - thread + - account type: string minItems: 1 name: context[] @@ -7502,14 +8230,14 @@ paths: 此过滤规则要应用的上下文。 示例: home, public - enum: - - home - - notifications - - public - - thread - - account in: formData items: + enum: + - home + - notifications + - public + - thread + - account type: string minItems: 1 name: context[] @@ -9209,6 +9937,281 @@ paths: summary: 删除横幅背景 tags: - accounts + /api/v1/push/subscription: + delete: + operationId: pushSubscriptionDelete + responses: + "200": + description: 被删除的通知订阅,或不存在。 + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - push + summary: 删除 Web 推送订阅 + description: 删除当前访问令牌关联的网页推送订阅。即使没有订阅,也会返回成功。 + tags: + - push + get: + operationId: pushSubscriptionGet + produces: + - application/json + responses: + "200": + description: 当前访问令牌的 Web 推送订阅。 + schema: + $ref: '#/definitions/webPushSubscription' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "404": + description: 当前访问令牌没有已关联的订阅。 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - push + summary: 获取 Web 推送订阅 + description: 获取当前访问令牌关联的 Web 推送订阅。 + tags: + - push + post: + consumes: + - application/json + - application/x-www-form-urlencoded + operationId: pushSubscriptionPost + parameters: + - description: Web 推送订阅将要发往的端点。 + in: formData + minLength: 1 + name: subscription[endpoint] + required: true + type: string + - description: 身份验证密钥,一个Base64编码的16字节随机数据字符串。 + in: formData + minLength: 1 + name: subscription[keys][auth] + required: true + type: string + - description: 用户代理公钥,一个使用 prime256v1 曲线生成的 ECDH 密钥对的公钥的Base64编码字符串。 + in: formData + minLength: 1 + name: subscription[keys][p256dh] + required: true + type: string + - default: false + description: 是否在有人关注你时接收推送通知? + in: formData + name: data[alerts][follow] + type: boolean + - default: false + description: 是否在有人向你发送关注请求时接收推送通知? + in: formData + name: data[alerts][follow_request] + type: boolean + - default: false + description: 是否在有人点赞你创建的贴文时接收推送通知? + in: formData + name: data[alerts][favourite] + type: boolean + - default: false + description: 是否在有人在贴文中提及你时接收推送通知? + in: formData + name: data[alerts][mention] + type: boolean + - default: false + description: 是否在有人转发你创建的贴文时接收推送通知? + in: formData + name: data[alerts][reblog] + type: boolean + - default: false + description: 是否在你参与或创建的投票结束时接收通知? + in: formData + name: data[alerts][poll] + type: boolean + - default: false + description: 是否在你订阅的某个账户发帖时接收推送通知? + in: formData + name: data[alerts][status] + type: boolean + - default: false + description: 是否在你互动过的贴文被编辑时接收推送通知? + in: formData + name: data[alerts][update] + type: boolean + - default: false + description: 是否在有新用户注册时接收推送通知? + in: formData + name: data[alerts][admin.sign_up] + type: boolean + - default: false + description: 是否在有人提交新的举报时接收推送通知? + in: formData + name: data[alerts][admin.report] + type: boolean + - default: false + description: 是否在有新的点赞待处理时接收推送通知? + in: formData + name: data[alerts][pending.favourite] + type: boolean + - default: false + description: 是否在有新的回复待处理时接收推送通知? + in: formData + name: data[alerts][pending.reply] + type: boolean + - default: false + description: 是否在有新的转发待处理时接收推送通知? + in: formData + name: data[alerts][pending.reblog] + type: boolean + - default: all + description: 接收推送通知的账号范围。 + enum: + - all + - followed + - follower + - none + in: formData + name: data[policy] + type: string + produces: + - application/json + responses: + "200": + description: 当前访问令牌关联的 Web 推送订阅。 + schema: + $ref: '#/definitions/webPushSubscription' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - push + summary: 创建 Web 推送订阅 + description: 使用当前访问令牌创建新的 Web 推送订阅,或替换现有订阅。 + tags: + - push + put: + consumes: + - application/json + - application/x-www-form-urlencoded + operationId: pushSubscriptionPut + parameters: + - default: false + description: 是否在有人关注你时接收推送通知? + in: formData + name: data[alerts][follow] + type: boolean + - default: false + description: 是否在有人请求关注你时接收推送通知? + in: formData + name: data[alerts][follow_request] + type: boolean + - default: false + description: 是否在有人点赞你创建的贴文时接收推送通知? + in: formData + name: data[alerts][favourite] + type: boolean + - default: false + description: 是否在有人在贴文中提及你时接收推送通知? + in: formData + name: data[alerts][mention] + type: boolean + - default: false + description: 是否在有人转发你创建的贴文时接收推送通知? + in: formData + name: data[alerts][reblog] + type: boolean + - default: false + description: 是否在你参与或发起的投票结束时接收推送通知? + in: formData + name: data[alerts][poll] + type: boolean + - default: false + description: 是否在你订阅的账号发帖时接收推送通知? + in: formData + name: data[alerts][status] + type: boolean + - default: false + description: 是否在你互动过的贴文被编辑时接收推送通知? + in: formData + name: data[alerts][update] + type: boolean + - default: false + description: 是否在有新用户注册时接收推送通知? + in: formData + name: data[alerts][admin.sign_up] + type: boolean + - default: false + description: 是否在有新举报被提交时接收推送通知? + in: formData + name: data[alerts][admin.report] + type: boolean + - default: false + description: 是否在有新点赞待处理时接收推送通知? + in: formData + name: data[alerts][pending.favourite] + type: boolean + - default: false + description: 是否在有新回复待处理时接收推送通知? + in: formData + name: data[alerts][pending.reply] + type: boolean + - default: false + description: 是否在有新转发待处理时接收推送通知? + in: formData + name: data[alerts][pending.reblog] + type: boolean + - default: all + description: 接收推送通知的账号范围。 + enum: + - all + - followed + - follower + - none + in: formData + name: data[policy] + type: string + produces: + - application/json + responses: + "200": + description: 当前访问令牌关联的 Web 推送订阅。 + schema: + $ref: '#/definitions/webPushSubscription' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - push + summary: 更新 Web 推送订阅 + description: 更新当前访问令牌关联的 Web 推送订阅。仅更新要接收的通知范围。 + tags: + - push /api/v1/reports: get: description: |- @@ -9431,7 +10434,8 @@ paths: name: status type: string x-go-name: Status - - description: |- + - collectionFormat: multi + description: |- 要附加的媒体附件 ID 数组。 如果提供了 media_ids,status 将变为可选,poll 不能使用。 @@ -9439,10 +10443,12 @@ paths: in: formData items: type: string - name: media_ids + name: media_ids[] type: array + uniqueItems: true x-go-name: MediaIDs - - description: |- + - collectionFormat: multi + description: |- 投票选项的数组。 如果提供了投票选项,media_ids 将不能使用,poll[expires_in] 必须提供。 in: formData @@ -9450,6 +10456,7 @@ paths: type: string name: poll[options][] type: array + uniqueItems: true x-go-name: PollOptions - description: |- 投票的开放时长,单位为秒。 @@ -9584,6 +10591,111 @@ paths: summary: 创建新贴文 tags: - statuses + put: + consumes: + - application/json + - application/x-www-form-urlencoded + operationId: statusEdit + parameters: + - description: |- + 贴文的文本内容。 + 如果提供了 media_ids,此项变为可选。 + 如果提供了文本内容,则投票(poll)也变为可选。 + in: formData + name: status + type: string + x-go-name: Status + - description: |- + 要附加的媒体附件 ID 数组。 + 如果提供了 media_ids,status 将变为可选,poll 不能使用。 + + 如果贴文以表单形式提交,应使用的键为 'media_ids[]',但如果是 JSON 或 XML,则键为 'media_ids'。 + in: formData + items: + type: string + name: media_ids + type: array + x-go-name: MediaIDs + - description: |- + 投票选项的数组。 + 如果提供了投票选项,media_ids 将不能使用,poll[expires_in] 必须提供。 + in: formData + items: + type: string + name: poll[options][] + type: array + x-go-name: PollOptions + - description: |- + 投票的开放时长,单位为秒。 + 如果提供了此项,media_ids 不能使用,poll[options] 必须提供。 + format: int64 + in: formData + name: poll[expires_in] + type: integer + x-go-name: PollExpiresIn + - default: false + description: 在此投票上允许多选。 + in: formData + name: poll[multiple] + type: boolean + x-go-name: PollMultiple + - default: true + description: 在投票结束前隐藏投票计数。 + in: formData + name: poll[hide_totals] + type: boolean + x-go-name: PollHideTotals + - description: 贴文和媒体附件应被标记为敏感。 + in: formData + name: sensitive + type: boolean + x-go-name: Sensitive + - description: |- + 在贴文内容之前显示的警告或主题文本。 + 贴文通常被折叠在此字段后。 + in: formData + name: spoiler_text + type: string + x-go-name: SpoilerText + - description: 此贴文的 ISO 639 语言代码。 + in: formData + name: language + type: string + x-go-name: Language + - description: 解析此贴文时使用的内容类型。 + enum: + - text/plain + - text/markdown + in: formData + name: content_type + type: string + x-go-name: ContentType + produces: + - application/json + responses: + "200": + description: 此贴文的最新版本。 + schema: + $ref: '#/definitions/status' + "400": + description: bad request 无效请求 + "401": + description: unauthorized 未授权 + "403": + description: forbidden 禁止 + "404": + description: not found 未找到 + "406": + description: not acceptable 不可接受 + "500": + description: internal server error 服务器内部错误 + security: + - OAuth2 Bearer: + - write:statuses + summary: 编辑贴文 + description: 按给定的表单参数编辑某条现有贴文。如果 content-type 为 'application/json',则参数也可以在请求体中以 JSON 形式给出。 + tags: + - statuses /api/v1/statuses/{id}: delete: description: |- @@ -10929,14 +12041,14 @@ paths: 此过滤规则要应用的上下文。 示例: home, public - enum: - - home - - notifications - - public - - thread - - account in: formData items: + enum: + - home + - notifications + - public + - thread + - account type: string minItems: 1 name: context[] @@ -11125,14 +12237,14 @@ paths: 此过滤规则要应用的上下文。 示例: home, public - enum: - - home - - notifications - - public - - thread - - account in: formData items: + enum: + - home + - notifications + - public + - thread + - account type: string minItems: 1 name: context[] @@ -11587,12 +12699,19 @@ paths: description: 若 GoToSocial 服务“在线” (即能够响应HTTP请求),则返回 200 状态码。 tags: - health - /nodeinfo/2.0: + /nodeinfo/{schema_version}: get: description: '对 nodeinfo 查询返回符合规范的 nodeinfo 响应。参见: https://nodeinfo.diaspora.software/schema.html' operationId: nodeInfoGet + parameters: + - description: 请求的 nodeinfo 规范版本。目前支持 2.0 和 2.1。 + in: path + name: schema_version + required: true + type: string produces: - application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#" + - application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#" responses: "200": description: "" diff --git a/docs/locales/zh/configuration/general.md b/docs/locales/zh/configuration/general.md index 56b1388d4..e1643496e 100644 --- a/docs/locales/zh/configuration/general.md +++ b/docs/locales/zh/configuration/general.md @@ -1,8 +1,6 @@ # 基础配置 -GoToSocial 的基础配置,包括域名、端口、绑定地址和传输协议等基本内容。 - -这里*真正*需要设置的只有 `host`,也就是你实例可以访问的域名,可能还需要设置 `port`。 +GoToSocial 的顶级配置,包括域名、端口、绑定地址和可信代理等基本信息。 ## 设置 diff --git a/docs/locales/zh/configuration/instance.md b/docs/locales/zh/configuration/instance.md index e1c8c8251..e6622cf2e 100644 --- a/docs/locales/zh/configuration/instance.md +++ b/docs/locales/zh/configuration/instance.md @@ -112,4 +112,47 @@ instance-deliver-to-shared-inboxes: true # 选项: [true, false] # 默认值: false instance-inject-mastodon-version: false + +# 字符串。hh:mm 格式的 24 小时制时间。 +# 示例: ["14:30", "00:00", "04:00"] +# 默认值: "23:00" (晚上11点)。 +instance-subscriptions-process-from: "23:00" + + +# 时间间隔。表示更新订阅的周期。 +# 示例:["24h", "72h", "12h"] +# 默认值: "24h"(每天一次)。 +instance-subscriptions-process-every: "24h" + +# 字符串。允许你自定义是否以及如何在 /api/v1|v2/instance +# 和 /nodeinfo 端点向爬虫提供统计数据。 +# +# 请注意,无论你在这里进行何种设置,/api/v1|v2/instance +# 端点都不会被 robots.txt 允许抓取,因为这些是客户端 +# API端点。 +# +# "" / 空字符串(默认模式): 在 instance 和 nodeinfo 端点提供准确的统计数据, +# 并在 robots.txt 中禁止爬虫抓取这些端点。这种模式相当于礼貌地 +# 要求爬虫不抓取,但不能保证它们会遵从这些规则, +# 因为遗憾的是,许多爬虫甚至不会检查robots.txt。 +# +# "zero": 在 instance 和 nodeinfo 端点提供全为零的统计数据, +# 并在 robots.txt 中禁止爬虫抓取这些端点。 +# 这种模式阻止行为不端的爬虫收集有关您的实例的统计数据, +# 因为所有收集的值都将为0。这(在统计数据方面) +# 是保护您的实例隐私的最安全方法。 +# +# "serve": 在 instance 和 nodeinfo 端点提供准确的统计数据, +# 并允许爬虫抓取这些端点。如果您希望为 +# 联邦宇宙统计信息收集项目做贡献,此模式将非常有用。 +# +# "baffle": 在 instance 和 nodeinfo 端点提供随机且荒谬的统计数据, +# 并在 robots.txt 中禁止爬虫抓取这些端点。 +# 这种模式可以用于使不尊重 robots.txt 的爬虫感到困惑。 +# 警告,此做法可能会引起不尊重 robots.txt 的爬虫开发者的怨恨, +# 因此可能会给您的实例带来风险。 +# +# 选项: ["", "zero", "serve", "baffle"] +# 默认: "" +instance-stats-mode: "" ``` diff --git a/docs/locales/zh/configuration/oidc.md b/docs/locales/zh/configuration/oidc.md index f4c6ef9bf..c5055e94b 100644 --- a/docs/locales/zh/configuration/oidc.md +++ b/docs/locales/zh/configuration/oidc.md @@ -10,7 +10,7 @@ GoToSocial 支持 [OpenID Connect](https://openid.net/connect/),这是一种 - 你希望将用户、账户、密码等的管理委托给外部服务,以简化管理。 - 你已经在外部系统中有很多用户,不想在 GoToSocial 中手动重新创建他们。 -!!! tip +!!! tip "提示" 如果用户尚不存在,且你的 IdP 没有返回非空的 `email` 作为 claims 的一部分,登录将会失败。这个 email 需要在此实例中是唯一的。尽管我们使用 `sub` claim 将外部身份与 GtS 用户关联,但创建用户时需要一个与之关联的 email。 ## 设置 diff --git a/docs/locales/zh/configuration/trusted_proxies.md b/docs/locales/zh/configuration/trusted_proxies.md new file mode 100644 index 000000000..eca63e17f --- /dev/null +++ b/docs/locales/zh/configuration/trusted_proxies.md @@ -0,0 +1,171 @@ +# 可信代理 + +为了正确执行[速率限制](../api/ratelimiting.md),GoToSocial 依赖于“可信代理”的概念,以准确确定访问你的实例的客户端的 IP 地址。 + +“可信代理”是一个中间网络跳转层,GoToSocial 可以配置为信任由该代理层提供的正确的客户端 IP 地址。 + +例如,如果你使用 Docker + Nginx 的反向代理配置中运行,那么 Nginx 的 Docker 网络地址应该被配置为可信代理,因为从广域互联网传入的所有流量将通过 Nginx 进入 GoToSocial。 + +如果没有正确设置 `trusted-proxies`, GoToSocial 将看到所有的入站客户端的 IP 地址都是同一个地址,这会导致速率限制的问题,因为 GoToSocial 使用客户端 IP 地址来执行速率限制。 + +## 总结:如何正确设置 `trusted-proxies` + +如果你的 `trusted-proxies` 设置没有正确配置,你可能会在实例的网页视图中看到以下警告(v0.18.0及以上版本): + +> 警告!此实例的配置中 trusted-proxies 的设置似乎不正确。这可能导致速率限制问题,进而导致联合问题。 +> +> 如果你是实例管理员,你应该通过将 `SUGGESTED_IP_RANGE` 添加到你的 trusted-proxies 来修复此问题。 + +要解决这个问题,可以复制消息中的IP范围,并编辑你的 `config.yaml` 文件,将IP范围添加到你的 `trusted-proxies` 中。 + +!!! tip "即使你没有看到上述警告,你也可能会遇到速率限制!" + 如果你使用的是低于 v0.18.0 版本的 GoToSocial,或者你在 Cloudflare(不推荐) 这样的 CDN 之后运行,你将不会看到警告消息。相反,你会在 GoToSocial 日志中看到所有客户端的 IP 都是同一个地址。在这种情况下,可以将重复出现的客户端IP值作为`SUGGESTED_IP_RANGE`。 + +在下面例子中,我们假定`SUGGESTED_IP_RANGE`为`172.17.0.1/16`(默认的Docker桥接网络子网)。 + +修改之前(默认配置): + +```yaml +trusted-proxies: + - "127.0.0.1/32" + - "::1" +``` + +修改之后(新配置): + +```yaml +trusted-proxies: + - "172.17.0.1/16" + - "127.0.0.1/32" + - "::1" +``` + +如果你使用[环境变量](../configuration/index.md#环境变量)来配置你的实例,可以通过设置环境变量`GTS_TRUSTED_PROXIES`为以逗号分隔的IP范围列表来配置`trusted-proxies`,如下所示: + +```env +GTS_TRUSTED_PROXIES="172.17.0.1/16,127.0.0.1/32,::1" +``` + +如果你使用 docker compose,你的 docker-compose.yaml 文件在更改后应如下所示(注意 yaml 使用 `:` 而不是 `=`): + +```yaml +################################ +# 其他配置内容 # +################################ + environment: + ############################ + # 其他环境变量 # + ############################ + ## 对于反向代理设置: + GTS_TRUSTED_PROXIES: "172.17.0.1/16,127.0.0.1/32,::1" +################################ +# 其他配置内容 # +################################ +``` + +一旦你完成了必要的配置更改,**重启你的实例**并刷新主页。 + +如果消息消失,则问题已解决! + +如果你仍然看到警告消息,但显示了一个不同的建议添加到`trusted-proxies`的 IP 范围,那么重复上述步骤,在你的配置中添加新的建议 IP 范围。 + +!!! tip "Cloudflare 的 IP 地址列表" + 如果你在 GoToSocial 实例前面使用 CDN/代理,例如 Cloudflare (不推荐),那么你可能需要将一个或多个 Cloudflare IP 地址添加到你的 `trusted-proxies` 中,以便速率限制正常工作。你可以在这里找到Cloudflare 的 IP 地址列表: https://www.cloudflare.com/ips/ + +## 我可能无法正确配置 `trusted-proxies`,可以直接禁用警告吗? + +在某些情况下,很难实际正确配置 `trusted-proxies` 来检测入站请求的真实客户端 IP,或者确保真实客户端 IP 是准确、但是仍显示为在私有网络内的。 + +例如,如果你在家用网络上运行 GoToSocial,且实例位于无法注入 `X-Forwarded-For` 标头的家庭互联网路由器之后,那么建议你添加到 `trusted-proxies` 的条目看起来会像 `192.168.x.x`,但将其添加到 `trusted-proxies` 后问题依然无法解决。 + +另一个例子是:你在家庭网络上运行 GoToSocial,GoToSocial 连接到家庭网络的路由器,并且你从同样在你家庭网络设备(比如笔记本或手机)上访问 Web 前端。在这种情况下,你的路由器可能会直接将你发送到你的 GoToSocial 实例,且你的请求不会离开家用网络,因此 GtS 将正确地认为*你的*客户端 IP 地址是一个私人网络地址,但*其他*从更广泛的互联网传入的请求将显示其真实的远程客户端 IP 地址。在这种情况下,`trusted-proxies` 的警告实际上不适用。 + +如果你已尝试编辑 `trusted-proxies` 设置,但仍看到警告,可能上面的一个例子适用于你。你可以通过以下两种方式之一继续: + +### 为家庭网络添加速率限制例外(推荐) + +如果 `trusted-proxies` 警告中的建议 IP 范围看起来像 `192.168.x.x`,但你在 GoToSocial 日志中仍看到其他客户端 IP 不以 `192.168` 开头,那么可以尝试只为家庭网络上的设备添加速率限制例外,同时对外部 IP 地址保持速率限制。 + +例如,如果你的建议是类似 `192.168.1.128/32`,那么将 `/32` 换为 `/24`,以便使范围覆盖 `192.168.1.0` -> `192.168.1.255`,并将其添加到 `config.yaml` 文件中的 `advanced-rate-limit-exceptions` 设置中。 + +默认设置(修改前): + +```yaml +advanced-rate-limit-exceptions: [] +``` + +设置修改后: + +```yaml +advanced-rate-limit-exceptions: + - "192.168.1.128/24" +``` + +如果你使用[环境变量](../configuration/index.md#环境变量)来配置实例,可以将环境变量 `GTS_ADVANCED_RATE_LIMIT_EXCEPTIONS` 设为以逗号分隔的 IP 范围列表,来配置 `advanced-rate-limit-exceptions`,如下所示: + +```env +GTS_ADVANCED_RATE_LIMIT_EXCEPTIONS="192.168.1.128/24" +``` + +如果使用 docker compose,修改后的 docker-compose.yaml 文件应如下所示(注意 yaml 使用 `: ` 而不是 `=`): + +```yaml +################################ +# 其他配置内容 # +################################ + environment: + ############################ + # 其他环境变量 # + ############################ + GTS_ADVANCED_RATE_LIMIT_EXCEPTIONS: "192.168.1.128/24" +################################ +# 其他配置内容 # +################################ +``` + +完成必要的配置更改后,**重启你的实例**并刷新主页。 + +### 完全关闭速率限制(最后手段) + +如果其他方法无效,你可以完全禁用速率限制,这也会禁用 `trusted-proxies` 检查和警告。 + +!!! warning "警告" + 完全关闭速率限制应被视为最后的手段,因为速率限制有助于保护你的实例免受骚扰信息和爬虫攻击。 + +要关闭速率限制,请在 `config.yaml` 中将 `advanced-rate-limit-requests` 设置为 0。 + +默认配置前: + +```yaml +advanced-rate-limit-requests: 300 +``` + +设置后: + +```yaml +advanced-rate-limit-requests: 0 +``` + +如果你使用[环境变量](../configuration/index.md#环境变量)来配置实例,可以通过将环境变量 `GTS_ADVANCED_RATE_LIMIT_REQUESTS` 设置为 0,来配置 `advanced-rate-limit-requests`,如下所示: + +```env +GTS_ADVANCED_RATE_LIMIT_REQUESTS="0" +``` + +如果使用 docker compose,改变后的 docker-compose.yaml 文件应如下所示(注意 yaml 使用 `: ` 而不是 `=`): + +```yaml +################################ +# 其他配置内容 # +################################ + environment: + ############################ + # 其他环境变量 # + ############################ + GTS_ADVANCED_RATE_LIMIT_REQUESTS: "0" +################################ +# 其他配置内容 # +################################ +``` + +完成必要的配置更改后,**重启你的实例**并刷新主页。 diff --git a/docs/locales/zh/federation/actors.md b/docs/locales/zh/federation/actors.md index b801a262f..36073b630 100644 --- a/docs/locales/zh/federation/actors.md +++ b/docs/locales/zh/federation/actors.md @@ -1,5 +1,13 @@ # 行为体与行为体属性 +## `Service` 与 `Person` 行为体 + +GoToSocial 将大多数账号视为[此处](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person)描述的 ActivityStreams `Person` 类型。 + +然而,被用户标记为机器人的账号将使用[此处](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-service)描述的 `Service` 类型。 + +这种类型的区分可供外站实例区分机器人账号和“普通”用户账号。 + ## 收件箱 GoToSocial 按照 [ActivityPub 规范](https://www.w3.org/TR/activitypub/#inbox),为行为体实现了收件箱。 diff --git a/docs/locales/zh/federation/posts.md b/docs/locales/zh/federation/posts.md index d536c9cae..0cb2ca02a 100644 --- a/docs/locales/zh/federation/posts.md +++ b/docs/locales/zh/federation/posts.md @@ -47,6 +47,58 @@ GoToSocial 外发话题标签提供的 `href` URL 指向一个提供 `text/html` GoToSocial 对给定 `text/html` 的内容不做任何保证,外站不应该将 URL 解释为规范的 ActivityPub ID/URI 属性。`href` URL 仅作为可能包含该话题标签更多信息的一个端点。 +## 表情符号(Emoji) + +GoToSocial 使用 `http://joinmastodon.org/ns#Emoji` 类型,以允许用户在贴文中添加自定义表情符号。 + +例如: + +```json +{ + "@context": [ + "https://gotosocial.org/ns", + "https://www.w3.org/ns/activitystreams", + { + "Emoji": "toot:Emoji", + "sensitive": "as:sensitive", + "toot": "http://joinmastodon.org/ns#" + } + ], + "type": "Note", + "content": "

这里有个臭烘烘的东西 -> :shocked_pikachu:

", + [...], + "tag": { + "icon": { + "mediaType": "image/png", + "type": "Image", + "url": "https://example.org/fileserver/01BPSX2MKCRVMD4YN4D71G9CP5/emoji/original/01AZY1Y5YQD6TREB5W50HGTCSZ.png" + }, + "id": "https://example.org/emoji/01AZY1Y5YQD6TREB5W50HGTCSZ", + "name": ":shocked_pikachu:", + "type": "Emoji", + "updated": "2022-11-17T11:36:05Z" + } + [...] +} +``` + +上述 `Note` 的 `content` 中的文本 `:shocked_pikachu:` 应当被客户端替换为表情符号图片的小型(内联)版本,在渲染 `Note` 时一并向用户展示。 + +表情符号的 `updated` 和 `icon.url` 属性可被外站实例用于判断它们对 GoToSocial 表情符号图片的表示是否是最新版本。必要时也可以在其 `id` URI 间接引用 `Emoji`,以便外站对照检查它们缓存的表情符号元数据是否未最新版本。 + +默认情况下,GoToSocial 对可以上传和发送的表情符号图片的大小设置了 50kb 的限制,并对可以联合并传入的表情符号图片大小设置了 100kb 的限制,但这两项设置都可由用户配置。 + +GoToSocial 可以发送和接收类型为 `image/png`、`image/jpeg`、`image/gif` 和 `image/webp` 的表情符号图片。 + +!!! info "附注" + 请注意,`tag` 属性可以是对象的数组,也可以是单个对象。 + +### `null` / 空 `id` 属性 + +一些服务端软件,如 Akkoma,将表情符号包含为贴文中的[匿名对象](https://www.w3.org/TR/activitypub/#obj-id)。也就是说,它们将 `id` 属性设置为 `null`,以表明该表情符号不能在任何特定的端点被间接引用。 + +在接收到这样的表情符号时,GoToSocial 会在数据库中为该表情符号生成一个伪 id,格式为 `https://[host]/dummy_emoji_path?shortcode=[shortcode]`,例如,`https://example.org/dummy_emoji_path?shortcode=shocked_pikachu`。 + ## 提及 GoToSocial 用户可以在贴文中使用 `@[用户名]@[域名]` 格式提及其他用户。例如,如果一个 GoToSocial 用户想提及实例 `example.org` 上的用户 `someone`,可以在贴文中包含 `@someone@example.org`。 @@ -160,14 +212,14 @@ GoToSocial 在解析传入的 `Object` 时使用 `content` 和 `contentMap` 属 如果 `contentMap` 有多个条目,则无法确定贴文的意图内容和语言,因为映射顺序不可预测。在这种情况下,尝试从 GoToSocial 实例的[配置语言](../configuration/instance.md)中选择与其中一种语言匹配的语言和内容条目。如果无法通过这种方式匹配语言,则从 `contentMap` 中随机选择一个语言和内容条目作为“主要”语言和内容。 -!!! Note +!!! note "注意" 在上述所有情况下,如果推断的语言无法解析为有效的 BCP47 语言话题标签,则语言将回退为未知。 ## 互动规则 GoToSocial 使用 `interactionPolicy` 属性告知外站给定帖文允许的互动类型(有前提)。 -!!! danger +!!! danger "危险" 互动规则旨在限制用户贴文上用户不希望的回复和其他互动的有害影响(例如,“回复家(reply guys)” —— 不请自来地发表冒失回复的人)。 @@ -229,7 +281,7 @@ GoToSocial 使用 `interactionPolicy` 属性告知外站给定帖文允许的互 ### 指定无人能进行的操作 -!!! note +!!! note "注意" 即使规则指定无人可互动,GoToSocial 仍做出默认假设。参见[默认假设](#默认假设)。 空数组或缺少/空的键表示无人能进行此互动。 diff --git a/docs/locales/zh/getting_started/index.md b/docs/locales/zh/getting_started/index.md index 68c948f11..448778999 100644 --- a/docs/locales/zh/getting_started/index.md +++ b/docs/locales/zh/getting_started/index.md @@ -2,7 +2,7 @@ 在部署 GoToSocial 之前,有几个关键点需要你仔细考虑,因为这些选择将影响你如何运行和管理 GoToSocial。 -!!! danger +!!! danger "危险" 在同一域名上切换不同实现是不被 Fediverse 支持的。这意味着如果你在 example.org 上运行 GoToSocial,而尝试切换到其他实现如 Pleroma/Akkoma、Misskey/Calckey 等,你会遇到联合问题。 @@ -24,7 +24,7 @@ GoToSocial 致力于为在小型设备上运行的使用场景优化,因此我 你应该在这种情况下预留一些余量,若有需要,可以[配置一些交换内存](#交换内存)。 -!!! tip +!!! tip "提示" 在内存受限的环境中,你可以将 `cache.memory-target` 设置为低于默认的 100MB (查看数据库配置选项[这里](../configuration/database.md#settings))。设置为 50MB 已被证明可以正常运行。 这将使总内存使用稍微降低,但代价是某些请求的延迟略高,因为 GtS 需要更频繁地访问数据库。 @@ -46,7 +46,7 @@ GoToSocial 使用存储来保存其数据库文件,以及存储和服务媒体 对于媒体存储,以及[缓存的外站媒体文件存储](../admin/media_caching.md),你应该预算大约 5GB-10GB 的空间。GoToSocial 会自动执行自我清理,在一段时间后从缓存中删除未使用的外站媒体。如果存储空间是个问题,你可以[调整媒体清理行为](../admin/media_caching.md#清理)以更频繁地清理和/或减少外站媒体的缓存时间。 -!!! info +!!! info "附注" 如果你的 sqlite.db 文件或 Postgres 容量在一开始增长很快,请不要惊慌,这是正常的。当你首次部署实例并开始联合时,你的实例会迅速发现并存储来自其他实例的账号和贴文。然而,随着实例的长期部署,这种增长会逐渐减缓,因为你会自然而然地看到更少的新账号(即,你的实例尚未见过并因此尚未在数据库中存储的账号)。 ### 单板计算机 @@ -106,7 +106,7 @@ SQLite 是默认的驱动,并已被证明在 1-30 用户范围内的实例表 无论你选择哪种数据库驱动,为了获得良好的性能,它们都应在快速、稳定的低延迟存储上运行。虽然可以在网络附加存储上运行数据库,但这会增加可变延迟和网络拥堵,还有源存储上的潜在 I/O 争用。 -!!! tip +!!! tip "提示" 请[备份你的数据库](../admin/backup_and_restore.md)。数据库包含实例和任何用户账户的加密密钥。如果丢失这些密钥,你将无法再次从同一域进行联合! ## 域名 @@ -119,7 +119,7 @@ SQLite 是默认的驱动,并已被证明在 1-30 用户范围内的实例表 如果你打算这样部署 GoToSocial 实例,请阅读[分域部署](../advanced/host-account-domain.md)文档以了解详细信息。 -!!! danger +!!! danger "危险" 无法在联合已经事实发生后安全地更改实例域名和账号域名。这需要重新生成数据库,并在任何已联合的服务器造成混乱情况。一旦你的实例域名和账号域名设置好,便不可更改。 ## TLS @@ -128,7 +128,7 @@ SQLite 是默认的驱动,并已被证明在 1-30 用户范围内的实例表 GoToSocial 内置 Lets Encrypt 证书配置支持。它也可以从磁盘加载证书。如果你有连接到 GoToSocial 的反向代理,可以在代理层处理 TLS。 -!!! tip +!!! tip "提示" 请确保配置使用现代版本的 TLS,TLSv1.2 及更高版本,以确保服务器和客户端之间的通信安全。当 GoToSocial 处理 TLS 终端时,这会自动为你配置。如果使用反向代理,请使用 [Mozilla SSL 配置生成器](https://ssl-config.mozilla.org/)。 ## 端口 @@ -140,7 +140,7 @@ GoToSocial 需要开放端口 `80` 和 `443`。 如果你无法在机器上开放 `443` 和 `80` 端口,不要担心!你可以在 GoToSocial 中配置这些端口,但还需要配置端口转发,以将 `443` 和 `80` 上的流量准确转发到你选择的端口。 -!!! tip +!!! tip "提示" 你应该在机器上配置防火墙,并配置一些防范暴力 SSH 登录尝试的保护措施。参阅我们的[防火墙文档](../advanced/security/firewall.md)以获取配置建议和可帮助你的工具。 ## 集群 / 多节点部署 @@ -167,7 +167,7 @@ GoToSocial 不支持[集群或任何形式的多节点部署](https://github.com 虽然可以在没有交换内存的情况下运行系统,但为了安全地做到这一点并确保一致的性能和服务可用性,你需要相应调整内核、系统和工作负载。这需要对内核的内存管理系统及你所运行的工作负载的内存使用模式有良好的理解。 -!!! tip +!!! tip "提示" 交换内存用于确保内核可以高效地回收内存。这在系统没有经历内存争用时也很有用,比如在进程启动时仅使用过的内存腾出。这允许更多活跃使用的东西被缓存于内存中。内存交换不是让你的程序变慢的原因。内存争用才是造成缓慢的原因。 [sysctl]: https://man7.org/linux/man-pages/man8/sysctl.8.html diff --git a/docs/locales/zh/getting_started/installation/container.md b/docs/locales/zh/getting_started/installation/container.md index 43c526896..f8c60f469 100644 --- a/docs/locales/zh/getting_started/installation/container.md +++ b/docs/locales/zh/getting_started/installation/container.md @@ -44,7 +44,7 @@ nano docker-compose.yaml * `snapshot`:指向当前在主分支上的代码。不保证稳定,可能经常出错。谨慎使用。 * `vX.Y.Z`:发布标签。这指向 GoToSocial 的特定、稳定的版本。 -!!! tip +!!! tip "提示" `latest` 和 `snapshot` 标签是动态标签,而 `vX.Y.Z` 标签是固定的。拉取动态标签的结果可能每天都会变化。同一系统上的 `latest` 可能与不同系统上的 `latest` 不同。建议使用 `vX.Y.Z` 标签,以便你始终确切知道运行的是 GoToSocial 的哪个版本。发布列表可以在[这里](https://github.com/superseriousbusiness/gotosocial/releases)找到,最新的发布在顶部。 ### 主机 @@ -87,7 +87,7 @@ nano docker-compose.yaml 如果你决定稍后设置/更改这些变量,请确保在更改后重新创建 GoToSocial 实例容器。 -!!! tip +!!! tip "提示" 有关将 config.yaml 文件中的变量名称转换为环境变量的帮助,请参阅[配置部分](../../configuration/index.md#environment-variables)。 diff --git a/docs/locales/zh/getting_started/installation/metal.md b/docs/locales/zh/getting_started/installation/metal.md index 0419e8cc4..425597299 100644 --- a/docs/locales/zh/getting_started/installation/metal.md +++ b/docs/locales/zh/getting_started/installation/metal.md @@ -33,7 +33,7 @@ cd /gotosocial 现在,下载与你运行的操作系统和架构相对应的最新 GoToSocial 发行版压缩包。 -!!! tip +!!! tip "提示" 你可以在[这里](https://github.com/superseriousbusiness/gotosocial/releases)找到按发布时间排列的发布列表,最新的发行版位于最上面。 例如,下载适用于 64 位 Linux 的版本: @@ -52,7 +52,7 @@ tar -xzf gotosocial_${GTS_VERSION}_${GTS_TARGET}.tar.gz 这将在你的当前目录放置 `gotosocial` 二进制文件,以及包含网页前端资源的 `web` 文件夹和包含示例配置文件的 `example` 文件夹。 -!!! danger +!!! danger "危险" 如果你想使用基于当前主分支代码的 GoToSocial 快照构建,可以从[这里](https://minio.s3.superseriousbusiness.org/browser/gotosocial-snapshots)下载最近的二进制 .tar.gz 文件(基于提交哈希)。仅在你很清楚自己的操作时使用,否则请使用稳定版。 ## 编辑配置文件 diff --git a/docs/locales/zh/getting_started/reverse_proxy/apache-httpd.md b/docs/locales/zh/getting_started/reverse_proxy/apache-httpd.md index f371178bc..e3d3fed13 100644 --- a/docs/locales/zh/getting_started/reverse_proxy/apache-httpd.md +++ b/docs/locales/zh/getting_started/reverse_proxy/apache-httpd.md @@ -48,7 +48,7 @@ sudo systemctl restart gotosocial.service ### 使用 mod_md 启用 TLS -!!! note +!!! note "注意" `mod_md` 自 Apache 2.4.30 开始可用,仍被视为实验性的。实际上,它在实践中表现良好,是最便捷的方法。 现在我们将配置 Apache HTTP 服务器来处理 GoToSocial 请求。 @@ -166,7 +166,7 @@ sudo systemctl restart apache2 ### 使用外部管理证书启用 TLS -!!! note +!!! note "注意" 我们有关于如何[配置 TLS 证书](../../advanced/certificates.md)的额外文档,其中还提供了不同发行版的其他内容和教程链接,可能值得查看。 如果你更喜欢手动设置或使用不同服务(如 Certbot)来管理 SSL,可以为你的 Apache HTTP 服务器使用更简单的设置。 diff --git a/docs/locales/zh/getting_started/reverse_proxy/index.md b/docs/locales/zh/getting_started/reverse_proxy/index.md index c0aa0df4f..6bc3813d8 100644 --- a/docs/locales/zh/getting_started/reverse_proxy/index.md +++ b/docs/locales/zh/getting_started/reverse_proxy/index.md @@ -11,7 +11,7 @@ GoToSocial 可以直接暴露到互联网上。不过,许多人更愿意使用 * 如果你使用了 Lets Encrypt,在 GoToSocial 中禁用它。将 `letsencrypt-enabled` 设置为 `false` * 配置反向代理以处理 TLS 并将请求代理到 GoToSocial -!!! warning +!!! warning "警告" 不要更改 `host` 配置选项的值。这必须保持为其他实例在互联网上看到的实际域名。相反,改变 `bind-address` 并更新 `port` 和 `trusted-proxies`。 ### 容器 @@ -41,3 +41,7 @@ GoToSocial 可以直接暴露到互联网上。不过,许多人更愿意使用 使用反向代理时,必须特别注意允许 WebSockets 正常工作。因为许多客户端应用程序使用 WebSockets 来流式传输你的时间线。WebSockets 不用于联合。 请确保阅读 [WebSocket](websocket.md) 文档,并相应地配置你的反向代理。 + +## 可信代理 + +使用反向代理时,可能会遇到速率限制和 `trusted-proxies` 相关的问题。如有任何问题,请查阅[可信代理](../../configuration/trusted_proxies.md)文档。 diff --git a/docs/locales/zh/getting_started/reverse_proxy/nginx.md b/docs/locales/zh/getting_started/reverse_proxy/nginx.md index 62b36f7a8..86f3923e9 100644 --- a/docs/locales/zh/getting_started/reverse_proxy/nginx.md +++ b/docs/locales/zh/getting_started/reverse_proxy/nginx.md @@ -2,7 +2,7 @@ 要使用 NGINX 作为 GoToSocial 的反向代理,你需要在服务器上安装它。如果你打算让 NGINX 处理 TLS,你还需要[配置 TLS 证书](../../advanced/certificates.md)。 -!!! tip +!!! tip "提示" 通过在 `server` 块中包含 `http2 on;` 来启用 NGINX 的 HTTP/2。这样可以加快客户端的体验。请参阅 [ngx_http_v2_module 文档](https://nginx.org/en/docs/http/ngx_http_v2_module.html#example)。 NGINX 已为[多个发行版打包](https://repology.org/project/nginx/versions)。你很可能可以使用发行版的包管理器来安装它。你也可以使用 Docker Hub 上发布的[官方 NGINX 镜像](https://hub.docker.com/_/nginx)通过容器运行 NGINX。 @@ -112,7 +112,7 @@ sudo systemctl restart nginx ## 设置 TLS -!!! warning +!!! warning "警告" 我们有关于如何[配置 TLS 证书](../../advanced/certificates.md)的附加文档,还提供了有关不同发行版的附加内容和教程链接,值得一看。 你现在可以运行 certbot,它将引导你完成启用 https 的步骤。 @@ -145,7 +145,7 @@ sudo systemctl start gotosocial 如果你再次打开 NGINX 配置,你会发现 Certbot 添加了一些额外的行。 -!!! warning +!!! warning "警告" 根据你设置 Certbot 时选择的选项,以及使用的 NGINX 版本,可能会有所不同。 ```nginx diff --git a/docs/locales/zh/getting_started/user_creation.md b/docs/locales/zh/getting_started/user_creation.md index 6b2479adc..9b5c220ea 100644 --- a/docs/locales/zh/getting_started/user_creation.md +++ b/docs/locales/zh/getting_started/user_creation.md @@ -29,7 +29,7 @@ 例如,将用户提升为管理员后,你需要重启 GoToSocial 服务器,以便从数据库加载新值。 -!!! tip +!!! tip "提示" 要查看其他可用的 CLI 命令,请点击[这里](../admin/cli.md)。 diff --git a/docs/locales/zh/mkdocs.yml b/docs/locales/zh/mkdocs.yml index 8de9afad6..b31b887ff 100644 --- a/docs/locales/zh/mkdocs.yml +++ b/docs/locales/zh/mkdocs.yml @@ -47,6 +47,7 @@ nav: - "配置": - "configuration/index.md" - "configuration/general.md" + - "configuration/trusted_proxies.md" - "configuration/database.md" - "configuration/web.md" - "configuration/instance.md" @@ -87,6 +88,7 @@ nav: - "admin/signups.md" - "admin/federation_modes.md" - "admin/domain_blocks.md" + - "admin/domain_permission_subscriptions.md" - "admin/request_filtering_modes.md" - "admin/robots.md" - "admin/cli.md" diff --git a/docs/locales/zh/repo/CONTRIBUTING.md b/docs/locales/zh/repo/CONTRIBUTING.md index 4da713ad3..0da934c40 100644 --- a/docs/locales/zh/repo/CONTRIBUTING.md +++ b/docs/locales/zh/repo/CONTRIBUTING.md @@ -148,7 +148,7 @@ Golang 的一个特点是,它所依赖的源代码管理路径与 `go.mod` 中 > > 把你的派生分支添加为 origin: > -> `git remote add origin git@github.com/yourgithubname/gotosocial` +> `git remote add origin git@github.com:yourgithubname/gotosocial` > 在第一次构建项目之前,一定要运行 `git fetch`。 @@ -488,7 +488,7 @@ GoToSocial 使用 [go-swagger](https://goswagger.io) 根据代码注释生成 Sw 如果你更改了任何 API 路径上的 Swagger 注释,可以通过运行以下命令在 `./docs/api/swagger.yaml` 生成一个新的 Swagger 文件: ```bash -swagger generate spec --scan-models --exclude-deps -o docs/api/swagger.yaml +go run github.com/go-swagger/go-swagger/cmd/swagger generate spec --scan-models --exclude-deps --output docs/api/swagger.yaml ``` ### CI/CD 配置 diff --git a/docs/locales/zh/repo/README.md b/docs/locales/zh/repo/README.md index 24b5591fc..5fd582f3d 100644 --- a/docs/locales/zh/repo/README.md +++ b/docs/locales/zh/repo/README.md @@ -17,7 +17,7 @@ GoToSocial 是一个用 Golang 编写的 [ActivityPub](https://activitypub.rocks 要从源代码构建,请查看 [CONTRIBUTING.md](https://github.com/superseriousbusiness/gotosocial/blob/main/docs/locales/zh/repo/CONTRIBUTING.md) 文件。 -这是实例首页的截图! +这是实例首页的截图!你也可以看一看本项目在 GoToSocial 上的官方账号: [https://gts.superseriousbusiness.org/@gotosocial](https://gts.superseriousbusiness.org/@gotosocial)。 ![GoToSocial 实例 goblin.technology 的首页截图。它展示了实例的基本信息,如用户数和贴文数等。](https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/overrides/public/instancesplash.png) @@ -126,7 +126,7 @@ GoToSocial 提供公开、不列出/悄悄公开、仅粉丝和私信(最好 ### 回复控制 -GoToSocial 允许你通过 [互动规则](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#default-interaction-policies) 选择谁可以回复你的贴文。你可以选择允许任何人回复贴文,仅允许朋友回复,等等。 +GoToSocial 允许你通过 [互动规则](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#默认互动规则) 选择谁可以回复你的贴文。你可以选择允许任何人回复贴文,仅允许朋友回复,等等。 ![互动规则设置](https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/overrides/public/user-settings-interaction-policy-1.png) @@ -146,7 +146,7 @@ GoToSocial 允许你选择将个人资料暴露为 RSS 订阅源,这样人们 ### 主题与自定义 CSS -用户可以为他们的账户页 [选择多种有趣的主题](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#select-theme),或甚至编写自己的 [自定义 CSS](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#custom-css)。 +用户可以为他们的账户页 [选择多种有趣的主题](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#选择主题),或甚至编写自己的 [自定义 CSS](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#自定义-CSS)。 管理员也可以轻松地为用户 [添加自定义主题](https://docs.gotosocial.org/zh-cn/latest/admin/themes/) 供用户选择。 @@ -225,10 +225,11 @@ GoToSocial 仅需约 250-350MiB 的 RAM,并且只要求极少的 CPU 频率, ### 隐私+安全功能 -- 内置 [Let's Encrypt](https://letsencrypt.org/) 的自动使用 HTTPS 支持。 -- 严格执行贴文可见性和屏蔽逻辑。 -- 导入与导出允许联合实例列表和拒绝联合实例列表。订阅社区创建的屏蔽列表(类似于用于实例间联合的广告拦截器!)(功能仍在进行中)。 +- 严格执行贴文隐私保护与屏蔽逻辑。 +- [支持配置通过网页访问账户时的贴文的可见范围](https://docs.gotosocial.org/zh-cn/latest/user_guide/settings/#个人资料上显示的贴文可见性级别)。 +- [导入/导出](https://docs.gotosocial.org/zh-cn/latest/admin/settings/#导入导出) 社区创建的域名允许和域名阻止列表,并[订阅](https://docs.gotosocial.org/zh-cn/latest/admin/domain_permission_subscriptions)这些列表。 - HTTP 签名认证:GoToSocial 在发送和接收消息时要求 [HTTP 签名](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12),以确保消息不能被篡改,身份不能被伪造。 +- 内置 [Let's Encrypt](https://letsencrypt.org/) 的自动使用 HTTPS 支持。 ### 多种联合模式 diff --git a/docs/locales/zh/repo/ROADMAP.md b/docs/locales/zh/repo/ROADMAP.md index 28d54752e..52bbb815d 100644 --- a/docs/locales/zh/repo/ROADMAP.md +++ b/docs/locales/zh/repo/ROADMAP.md @@ -71,7 +71,7 @@ - [x] **v2 过滤规则** -- 实现过滤器 API 的第二版。 - [x] **静音账户** -- 静音账户以防止其帖文出现在主页时间线上(可选:限制时间段)。 - [x] **无评论区的帖文** -- 设计无评论区帖文的相关逻辑,让用户创建无评论区的帖文。 -- [ ] **屏蔽/允许列表订阅** -- 允许实例管理员订阅纯文本的示例屏蔽/允许列表。(大部分工作已经完成) +- [x] **屏蔽/允许列表订阅** -- 允许实例管理员为其实例订阅屏蔽/允许列表。 - [x] **私信对话视图** -- 让用户能够轻松浏览他们参与的所有私信对话。 - [ ] **Oauth 令牌管理** -- 通过设置面板创建/查看/吊销 OAuth 令牌。 - [ ] **贴文编辑支持** -- 编辑已创建的贴文,而无需删除并重新编辑。并正确地将编辑传播出去。 diff --git a/docs/locales/zh/user_guide/migration.md b/docs/locales/zh/user_guide/migration.md index 9e519159c..a6ffbf24b 100644 --- a/docs/locales/zh/user_guide/migration.md +++ b/docs/locales/zh/user_guide/migration.md @@ -6,10 +6,10 @@ GoToSocial 支持使用 `Move` 活动进行账号迁移。 迁移是软件无关的,因此你可以将账号迁移到其它软件或从任何支持 `Move` 活动的软件发起迁移,无论具体的软件是什么。例如,你可以将 GoToSocial 账号迁移到 Mastodon 账号,将 Mastodon 账号迁移到 GoToSocial 账号,将 GoToSocial 账号迁移到或从 Akkoma、Misskey、GoToSocial 等。 -!!! tip +!!! tip "提示" 根据目标账号所在软件的不同,目标账号的 URI(用于别名和迁移)应该类似于 `https://mastodon.example.org/users/account_you_are_moving_to`。如果你不确定使用哪种格式,请咨询你要迁移或设置别名的实例管理员。 -!!! warning +!!! warning "警告" GoToSocial 要求 7 天的账号迁移冷却期,以防止过度切换实例(以及潜在的屏蔽规避风险)。 如果任何一个发起新迁移尝试的账号在最近七天内已迁移,GoToSocial 将拒绝进行迁移,直到上一次迁移过去七天位置。 @@ -71,8 +71,8 @@ GoToSocial 支持使用 `Move` 活动进行账号迁移。 一旦触发从其他账号到 GoToSocial 账号的迁移,你唯一需要做的就是在新(GoToSocial)账号上接受来自旧账号粉丝的关注请求。 -!!! tip +!!! tip "提示" 为了省去麻烦,可以考虑在触发迁移前将 GoToSocial 账号设置为不需要批准新的关注请求。迁移完成后再开启关注请求审核。否则,你将需要手动批准每个从旧账号迁移的粉丝。 -!!! tip +!!! tip "提示" 迁移账号后,可能需要将之前账号的关注列表导入 GoToSocial 账号。[在此查看](./settings.md#import)如何通过设置面板完成此操作的详细信息。 diff --git a/docs/locales/zh/user_guide/posts.md b/docs/locales/zh/user_guide/posts.md index 911eb2beb..87ef71871 100644 --- a/docs/locales/zh/user_guide/posts.md +++ b/docs/locales/zh/user_guide/posts.md @@ -36,7 +36,7 @@ GoToSocial 为贴文提供 Mastodon 风格的隐私设置。从最私密到最 ### 互关可见 -!!! warning +!!! warning "警告" 目前暂时无法将帖文可见性设为“互关可见”。 `互关可见` 的贴文只会显示给贴文作者和与作者*互相关注*的人。换句话说,只有在满足两个条件时,其他人才能看到: @@ -135,14 +135,14 @@ GoToSocial 允许你在贴文中附加媒体文件,大多数客户端会在贴 为了避免泄漏你的位置信息,GoToSocial 努力在上传媒体时通过清零 Exif 数据点移除 Exif 信息。 -!!! danger +!!! danger "危险" 为了方便和保护隐私,GoToSocial 在上传图片文件时会自动移除 Exif 标签。然而,**无法自动移除 mp4 视频的 Exif 数据**(参见 [#2577](https://github.com/superseriousbusiness/gotosocial/issues/2577))。 在你将视频上传至 GoToSocial 之前,建议确保该视频的 Exif 数据标签已经被移除。你可以在线找到多种工具和服务来做到这一点。 为防止 Exif 位置信息在一开始被写入图片或视频中,你还可以关闭设备摄像头应用中的位置标记(通常称为地理标记)。 -!!! tip +!!! tip "提示" 即使你在上传图片或视频之前已完全移除所有 Exif 元数据,恶意用户仍然可以通过媒体本身的内容推断出你的位置信息。 如果你属于在生产中有保密需要的组织,或正在被跟踪或监视,你可能需要考虑不要发布任何可能含有你位置线索的媒体。 @@ -285,6 +285,9 @@ GoToSocial 允许你在贴文中附加媒体文件,大多数客户端会在贴 你可以在 GoToSocial 贴文中包含任意数量的话题标签,而且每个话题标签的长度限制为 100 个字符。 +!!! tip "提示" + 要结束一个话题标签,你只需在话题标签名后输入空格。例如,在文本 `这道 #鸡汤 十分美味` 中,话题标签由空格终止,因此 `#鸡汤` 成为话题标签。但是,你也可以使用管道字符 `|`,或使用 Unicode 字符 `\u200B` (零宽不换行空格)或 `\uFEFF` (零宽空格),来创建“词语片段”话题标签。例如,在 `这道 #鸡|汤 十分美味` 中,只有 `#鸡` 成为话题标签。同理,对于文本 `这道 #鸡​汤 十分美味` (`鸡` 和 `汤` 之间有一个零宽空格),只有 `#鸡` 成为话题标签。有关零宽空格的更多信息,参见:https://en.wikipedia.org/wiki/Zero-width_space。 + ## 输入净化 为了不传播脚本、漏洞以及不稳定的 HTML,GoToSocial 执行以下类型的输入净化: diff --git a/docs/locales/zh/user_guide/settings.md b/docs/locales/zh/user_guide/settings.md index 37ca049a7..9b51d9ee3 100644 --- a/docs/locales/zh/user_guide/settings.md +++ b/docs/locales/zh/user_guide/settings.md @@ -88,14 +88,14 @@ GoToSocial 提供主题供你选择,以更改账户的外观和氛围。 此设置不会影响你的贴文在 ActivityPub 协议和客户端中的可见性,因此即便你选择不在网页版账户页显示任何贴文,只要他人是你的粉丝、你的贴文被转发到他们的时间线,或使用链接搜索你的某个贴文,他们仍然可以看到的贴文。 -!!! warning +!!! warning "警告" 请注意,此设置的更改也会应用于之前的贴文。 也就是说,如果你之前发布了一条“不列出”可见性的贴文,而当时你的网页版账户页被设置为仅显示公开贴文,此时如果你更改此设置为一并显示公开和不列出,那你之前发布的“不列出”贴文将会与公开贴文一起显示在你的网页版账户页上。 同样地,如果你选择不显示任何贴文,那么所有贴文将从你的网页版账户页中隐藏,无论它们是在何时创建,也无论当时此选项被设置为什么。这种情况将持续直到你再次更改此设置。 -!!! tip +!!! tip "提示" 结合(域名)屏蔽,如果有人通过公开贴文骚扰你,这是一种很好的“紧急”设置。虽然它不会阻止在 ActivityPub 客户端中可以看到你的贴文的人,但至少会防止他们无需身份验证就通过浏览器点击查看你的贴文,并通过 URL 轻松与他人分享。 #### 手动批准关注请求(即锁定帐户) @@ -121,10 +121,10 @@ GoToSocial 提供主题供你选择,以更改账户的外观和氛围。 将可发现性标记打开可能需要一周或更长时间才会生效,账户不会立即出现在搜索引擎结果中。 -!!! tip +!!! tip "提示" 为了避免暴露给爬虫,新帐户的可发现性默认为 false。但对于希望被抓取的面向公众的帐户,将其设置为 true 是有用的。 -!!! info +!!! info "附注" 可发现性设置是关于**账户的可发现性**,而不是贴文的可被搜索性。这与 Mastodon 实例或其他使用全文搜索的实例的贴文索引无关! #### 启用公开贴文的 RSS 源 @@ -133,7 +133,7 @@ GoToSocial 提供主题供你选择,以更改账户的外观和氛围。 此源仅包括设置为“公开”的贴文(参见 [隐私设置](./posts.md#隐私设置))。 -!!! warning +!!! warning "警告" 公开您的 RSS 源允许*任何人*匿名订阅您公开贴文的更新,绕过关注和关注请求。 #### 隐藏你关注/被关注的人 @@ -152,7 +152,7 @@ GoToSocial 提供主题供你选择,以更改账户的外观和氛围。 请参阅 [自定义 CSS](./custom_css.md) 页面,了解有关为账户编写自定义 CSS 的一些提示。 -!!! tip +!!! tip "提示" 你在此框中添加的任何自定义 CSS 都将在*选择主题之后*应用,因此你可以选择一个喜欢的预设主题,然后进行自己的调整! ## 贴文 @@ -196,7 +196,7 @@ markdown 设置表示你的贴文应被按 Markdown 格式解析,这是一种 如果你想将所有规则重置为初始默认值,可以点击 `重置为默认值` 按钮。 -!!! danger +!!! danger "危险" 虽然 GoToSocial 尊重互动规则,但不能保证其他服务端软件也会这样做,即使你的实例禁止某些互动,其他服务器上的账户可能仍会向其粉丝发送(被禁止的)贴文回复和转发。 随着更多 ActivityPub 服务端推出互动规则支持,这个问题有望减少,但在此期间,GoToSocial 只能在“尽力而为”范围内进行尝试,以根据你设定的规则限制与贴文的互动。 @@ -209,14 +209,14 @@ markdown 设置表示你的贴文应被按 Markdown 格式解析,这是一种 输入新电子邮箱地址,并点击“更改电子邮箱地址”后,必须打开新电子邮件地址的收件箱,并通过提供的链接确认地址。完成后,你的电子邮箱地址更改将被确认。 -!!! info +!!! info "附注" 如果你的实例使用 OIDC 作为授权/身份提供商,你可以通过设置面板更改电子邮箱地址,但只会影响 GoToSocial 用于联系你的电子邮箱地址,而不会更改用于登录账户的电子邮箱地址。要更改此项,应联系你的 OIDC 提供商。 ### 更改密码 你可以使用面板的更改密码部分为账户设置新密码。出于安全原因,你必须提供当前密码以验证更改。 -!!! info +!!! info "附注" 如果你的实例使用 OIDC 作为授权/身份提供商,你将无法通过 GoToSocial 设置面板更改密码,此时应联系你的 OIDC 提供商。 有关 GoToSocial 如何管理密码的更多信息,请参阅[密码管理文档](./password_management.md)。 @@ -249,7 +249,7 @@ markdown 设置表示你的贴文应被按 Markdown 格式解析,这是一种 然后,使用下拉菜单选择通过 CSV 文件上传的数据类型。 -!!! warning +!!! warning "警告" 在选择“类型”时要小心,否则可能会意外封禁你计划关注的一堆账户,反之亦然! 然后,选择是要**合并**新数据到 GoToSocial 账户中该类型的现有数据,还是要用 CSV 文件中包含的数据**覆盖**现有数据。 @@ -264,5 +264,5 @@ markdown 设置表示你的贴文应被按 Markdown 格式解析,这是一种 合并和覆盖操作都是幂等的,这通常意味着现有数据和 CSV 文件中的重复条目不会产生问题,如果需要重试导入,可以多次导入相同的数据。 -!!! info +!!! info "附注" 由于各种原因,通过导入不可能一定会重新创建上传的 CSV 文件中的每个条目。例如,假设你试图导入包含 `example_account` 的关注 CSV,但 `example_account` 的实例已下线,或者它们的实例封禁了你的实例,或你的实例封禁了它们的实例等。在这种情况下,将无法创建对 `example_account` 的关注。 From a6d1f5bf2c81f26200bc12cfeb61e9a2965b933e Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Sun, 9 Feb 2025 02:13:28 -0800 Subject: [PATCH 04/14] [bugfix] Reduce Web Push record size (#3762) --- internal/webpush/realsender.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/webpush/realsender.go b/internal/webpush/realsender.go index 919cea788..363f5d8c2 100644 --- a/internal/webpush/realsender.go +++ b/internal/webpush/realsender.go @@ -192,6 +192,11 @@ func (r *realSender) sendToSubscription( // while waiting for the client to retrieve them. TTL = 48 * time.Hour + // recordSize limits how big our notifications can be once padding is applied. + // To be polite to applications that need to relay them over services like APNS, + // which has a max message size of 4 kB, we set this comfortably smaller. + recordSize = 2048 + // responseBodyMaxLen limits how much of the Web Push server response we read for error messages. responseBodyMaxLen = 1024 ) @@ -232,6 +237,7 @@ func (r *realSender) sendToSubscription( }, &webpushgo.Options{ HTTPClient: r.httpClient, + RecordSize: recordSize, Subscriber: "https://" + config.GetHost(), VAPIDPublicKey: vapidKeyPair.Public, VAPIDPrivateKey: vapidKeyPair.Private, @@ -346,8 +352,9 @@ func formatNotificationTitle( // or the beginning of the bio text of the related account. func formatNotificationBody(apiNotification *apimodel.Notification) string { // bodyMaxLen is a polite maximum length for a Web Push notification's body text, in bytes. Note that this isn't - // limited per se, but Web Push servers may reject anything with a total request body size over 4k. - const bodyMaxLen = 3000 + // limited per se, but Web Push servers may reject anything with a total request body size over 4k, + // and we set a lower max size above for compatibility with mobile push systems. + const bodyMaxLen = 1500 var body string if apiNotification.Status != nil { From 42bbbaadb2d83ba1849a659ca91cd0f31632fc55 Mon Sep 17 00:00:00 2001 From: CDN Date: Sun, 9 Feb 2025 19:22:41 +0800 Subject: [PATCH 05/14] [feature/frontend] add light mode color scheme of base css, adapt to prefers-color-scheme (#3765) --- web/assets/themes/blurple-light.css | 4 +++ web/assets/themes/brutalist-dark.css | 7 +++++ web/assets/themes/midnight-trip.css | 4 +++ web/assets/themes/rain-forest.css | 9 ++++++ web/assets/themes/soft.css | 6 ++++ web/source/css/_colors.css | 43 ++++++++++++++++++++++++++-- web/source/css/index.css | 4 +++ web/source/css/profile.css | 5 ++++ 8 files changed, 80 insertions(+), 2 deletions(-) diff --git a/web/assets/themes/blurple-light.css b/web/assets/themes/blurple-light.css index 5076ba9cc..eb45ffb30 100644 --- a/web/assets/themes/blurple-light.css +++ b/web/assets/themes/blurple-light.css @@ -23,6 +23,10 @@ --blue2: var(--blurple5); --blue3: var(--blurple6); + /* Use hardcoded grey as gray get restyled in light mode */ + --gray1: #2a2b2f; + --gray2: #35363b; + /* Basic page styling (background + foreground) */ --bg: var(--blurple1); --bg-accent: var(--white2); diff --git a/web/assets/themes/brutalist-dark.css b/web/assets/themes/brutalist-dark.css index baccaa046..4cf8cd655 100644 --- a/web/assets/themes/brutalist-dark.css +++ b/web/assets/themes/brutalist-dark.css @@ -63,6 +63,13 @@ html, body { .profile .profile-header .basic-info .avatar-image-wrapper { border: var(--single-border); } + +.profile .statuses .rss-icon .fa { + /* enforce dark mode style */ + background: linear-gradient(to right, var(--almost-black) 100%, transparent 0) no-repeat center center; + background-size: 1.2rem 1.4rem; +} + .status .status-header > address > a .avatar { border: var(--single-border); } diff --git a/web/assets/themes/midnight-trip.css b/web/assets/themes/midnight-trip.css index d817d56ae..29c143abc 100644 --- a/web/assets/themes/midnight-trip.css +++ b/web/assets/themes/midnight-trip.css @@ -17,6 +17,10 @@ --blue1: var(--acid-green-dark); --blue2: var(--acid-green-light); --blue3: var(--acid-green); + + /* enforce dark mode style */ + --white1: #fafaff; + --white2: #b3b5c6; } /* Main page background */ diff --git a/web/assets/themes/rain-forest.css b/web/assets/themes/rain-forest.css index 3a890ef64..62763cec3 100644 --- a/web/assets/themes/rain-forest.css +++ b/web/assets/themes/rain-forest.css @@ -34,6 +34,9 @@ /* dark blues */ --gray2: #29485A; /* black forest blue */ --gray4: #2B3246; /* vintage dark blue */ + /* enforce dark mode style */ + --white1: #fafaff; + --white2: #b3b5c6; /* statuses */ --status-bg: var(--dgreen1); --status-focus-bg: var(--dgreen1); @@ -87,6 +90,12 @@ box-shadow: none; /* no "glow" for buttons */ border-top: 0.1rem solid var(--sunny); } +/* RSS icon */ +.profile .statuses .rss-icon .fa { + background: linear-gradient(to right, var(--gray2) 100%, transparent 0) no-repeat center center; + background-size: 1.2rem 1.4rem; +} + /* Block quotes */ blockquote { background-color: var(--quotebg); diff --git a/web/assets/themes/soft.css b/web/assets/themes/soft.css index 05923d91d..691558bee 100644 --- a/web/assets/themes/soft.css +++ b/web/assets/themes/soft.css @@ -18,6 +18,12 @@ --orange2: var(--blue1); --br: 0.8rem; --br-inner: 0.4rem; + /* Use hardcoded grey as gray get re-styled in light mode */ + --white1: #fafaff; + --gray1: #2a2b2f; + --gray2: #35363b; + --gray3: #45464e; + --gray8: #696a75; /* Basic page styling (background + foreground) */ --bg: var(--soft-pink); diff --git a/web/source/css/_colors.css b/web/source/css/_colors.css index c050dfe40..f8fb979a1 100644 --- a/web/source/css/_colors.css +++ b/web/source/css/_colors.css @@ -24,6 +24,8 @@ /* Color definitions */ +/* Dark mode - default */ + /* Foreground */ $white1: #fafaff; /* default text color, contrast >= 5.0 with all $grays */ $white2: #b3b5c6; /* less important text, can be used with $gray1 (6.8), $gray2 (5.5), $gray3 (4.9), $gray4 (4.5) */ @@ -94,7 +96,7 @@ $no-img-desc-fg: $gray1; $bg-sensitive: $gray1; -$boxshadow: 0 0.4rem 1rem -0.1rem rgba(0,0,0,0.15); +$boxshadow: 0 0.4rem 1rem -0.1rem rgba(0, 0, 0, 0.15); $boxshadow-border: 0.08rem solid $gray1; $avatar-border: $orange2; @@ -129,4 +131,41 @@ $plyr-badge-background: $bg-accent; $plyr-video-controls-background: $bg-accent; $plyr-badge-text-color: $fg; $plyr-badge-border-radius: $br; -$plyr-video-progress-buffered-background: $gray8; \ No newline at end of file +$plyr-video-progress-buffered-background: $gray8; + +/* Light mode */ + +$white: #fafaff; /* we still use white for something */ + +@media (prefers-color-scheme: light) { + :root { + $white1: #000000; /* default text color, contrast >= 5.0 with all $grays */ + $white2: #59595F; /* less important text, can be used with $gray1 (8.5) ~ $gray5 (5.0) */ + + /* Background shades, contrast >= 5.0 with $white1 (#000000) */ + $gray1: #ffffff; + $gray2: #f6f6f6; + $gray3: #ededed; + $gray4: #e4e4e4; + $gray5: #dbdbdb; + $gray6: #d2d2d2; + $gray7: #c9c9c9; + $gray8: #c0c0c0; + + $orange1: #c75300; /* Used for non-text accent colors, can be used as background: $gray1 for text color (contrast 4.5)*/ + $orange2: #bd4f00; /* hover/selected accent to $orange1, can be used with $gray1 (5.7), $gray2 (4.5) */ + + $blue1: #247cb3; /* lighter blue for smaller elements (borders), can only be used with $gray1 (4.5) */ + $blue2: #166ba0; /* all-round accent color, can be used with $gray1 (5.7), $gray2 (5.3), $gray3 (4.9), $gray4 (4.5) */ + $blue3: #106193; /* hover/selected accent to $blue2, can be used with $gray1 (6.6), $gray2 (6.1), $gray3 (5.6), $gray4 (5.2), $gray5 (4.8) */ + + $error1: #ffc1c1; /* Error border/foreground text, can be used with $error2 (5.0), $white1 (13.6), $white2 (4.5) */ + $error2: #aa0000; /* Error background text, can be used with $error1 (5.0), $gray1 (7.7), $gray2 (7.1), $gray3 (6.62) */ + $error3: #d93636; /* Error button background text, can be used with $white1 (4.53) */ + $error-link: #abd4ff; /* Error link text, can be used with $error2 (5.56) */ + + $green1: #367400; + + $info-bg: $blue1; + } +} \ No newline at end of file diff --git a/web/source/css/index.css b/web/source/css/index.css index 9f8e662d4..a7c18c6dd 100644 --- a/web/source/css/index.css +++ b/web/source/css/index.css @@ -70,6 +70,10 @@ .activitypub-logo { background: $fg; + /* light mode */ + @media (prefers-color-scheme: light) { + background: none; + } box-shadow: $boxshadow; border-radius: $br; max-width: 100%; diff --git a/web/source/css/profile.css b/web/source/css/profile.css index d9e9bc093..1296b8927 100644 --- a/web/source/css/profile.css +++ b/web/source/css/profile.css @@ -298,6 +298,11 @@ */ background: linear-gradient(to right, $white1 100%, transparent 0) no-repeat center center; background-size: 1.2rem 1.4rem; + /* light mode */ + @media (prefers-color-scheme: light) { + background: linear-gradient(to right, $white 100%, transparent 0) no-repeat center center; + background-size: 1.2rem 1.4rem; + } } } From 05e89af4ecf81eae9d725e0f61ffe7e14b55d7ed Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 9 Feb 2025 12:23:06 +0100 Subject: [PATCH 06/14] [chore/frontend] Tweak display of "edited" in web UI a bit (#3766) --- web/source/css/status.css | 2 +- web/template/status_info.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/source/css/status.css b/web/source/css/status.css index f08310921..8ab0471fb 100644 --- a/web/source/css/status.css +++ b/web/source/css/status.css @@ -438,7 +438,7 @@ main { column-gap: 1rem; .edited-at { - font-style: italic; + font-size: smaller; } } diff --git a/web/template/status_info.tmpl b/web/template/status_info.tmpl index 366300071..a66ca05c4 100644 --- a/web/template/status_info.tmpl +++ b/web/template/status_info.tmpl @@ -30,7 +30,7 @@
Edited
- (last edited ) + (edited )
{{ end }} From 128fcc871cc61986f545c9c14356a092fdc3fc8e Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 9 Feb 2025 12:23:16 +0100 Subject: [PATCH 07/14] [bugfix] Fix missing `hasChanged` func (#3764) --- cmd/gotosocial/action/testrig/testrig.go | 5 +++++ web/source/settings/lib/form/index.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go index b19325234..05704ecb6 100644 --- a/cmd/gotosocial/action/testrig/testrig.go +++ b/cmd/gotosocial/action/testrig/testrig.go @@ -30,6 +30,7 @@ import ( "github.com/gin-gonic/gin" "github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action" + "github.com/superseriousbusiness/gotosocial/internal/admin" "github.com/superseriousbusiness/gotosocial/internal/api" apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" "github.com/superseriousbusiness/gotosocial/internal/cleaner" @@ -133,6 +134,10 @@ var Start action.GTSAction = func(ctx context.Context) error { // Initialize caches and database state.DB = testrig.NewTestDB(state) + // Set Actions on state, providing workers to + // Actions as well for triggering side effects. + state.AdminActions = admin.New(state.DB, &state.Workers) + // New test db inits caches so we don't need to do // that twice, we can just start the initialized caches. state.Caches.Start() diff --git a/web/source/settings/lib/form/index.ts b/web/source/settings/lib/form/index.ts index 878b7c79b..047fdf5aa 100644 --- a/web/source/settings/lib/form/index.ts +++ b/web/source/settings/lib/form/index.ts @@ -103,6 +103,7 @@ function value(name: string, initialValue: T) { name, Name: "", value: initialValue, + hasChanged: () => true, }; } From ce7ba8f4986845d39dfae284f156f14af677a7b4 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 9 Feb 2025 13:52:52 +0100 Subject: [PATCH 08/14] [bugfix] Fix POST to create account endpoint (#3767) --- internal/processing/user/create_test.go | 74 +++++++++++++++++++++++++ internal/processing/user/user.go | 1 + internal/processing/user/user_test.go | 10 +++- 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 internal/processing/user/create_test.go diff --git a/internal/processing/user/create_test.go b/internal/processing/user/create_test.go new file mode 100644 index 000000000..9781a4214 --- /dev/null +++ b/internal/processing/user/create_test.go @@ -0,0 +1,74 @@ +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package user_test + +import ( + "context" + "net" + "testing" + + "github.com/stretchr/testify/suite" + apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" +) + +type CreateTestSuite struct { + UserStandardTestSuite +} + +func (suite *CreateTestSuite) TestCreateOK() { + var ( + ctx = context.Background() + app = suite.testApps["application_1"] + appToken = suite.testTokens["local_account_1_client_application_token"] + form = &apimodel.AccountCreateRequest{ + Reason: "a long enough explanation of why I am doing api calls", + Username: "someone_new", + Email: "someone_new@example.org", + Password: "a long enough password for this endpoint", + Agreement: true, + Locale: "en-us", + IP: net.ParseIP("192.0.2.128"), + } + ) + + // Create user via the API endpoint. + user, errWithCode := suite.user.Create(ctx, app, form) + if errWithCode != nil { + suite.FailNow(errWithCode.Error()) + } + + // Load the app-level access token that was just used. + appAccessToken, err := suite.oauthServer.LoadAccessToken(ctx, appToken.Access) + if err != nil { + suite.FailNow(err.Error()) + } + + // Create a user-level access token for the new user. + userAccessToken, err := suite.user.TokenForNewUser(ctx, appAccessToken, app, user) + if err != nil { + suite.FailNow(err.Error()) + } + + // Check returned user-level access token. + suite.NotEmpty(userAccessToken.AccessToken) + suite.Equal("Bearer", userAccessToken.TokenType) +} + +func TestCreateTestSuite(t *testing.T) { + suite.Run(t, &CreateTestSuite{}) +} diff --git a/internal/processing/user/user.go b/internal/processing/user/user.go index cd8ab9900..5efb89061 100644 --- a/internal/processing/user/user.go +++ b/internal/processing/user/user.go @@ -41,6 +41,7 @@ func New( return Processor{ state: state, converter: converter, + oauthServer: oauthServer, emailSender: emailSender, } } diff --git a/internal/processing/user/user_test.go b/internal/processing/user/user_test.go index 2a9e0a89f..72fd22117 100644 --- a/internal/processing/user/user_test.go +++ b/internal/processing/user/user_test.go @@ -23,6 +23,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/email" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/processing/user" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/typeutils" @@ -34,9 +35,11 @@ type UserStandardTestSuite struct { emailSender email.Sender db db.DB state state.State + oauthServer oauth.Server - testUsers map[string]*gtsmodel.User - + testApps map[string]*gtsmodel.Application + testTokens map[string]*gtsmodel.Token + testUsers map[string]*gtsmodel.User sentEmails map[string]string user user.Processor @@ -51,9 +54,12 @@ func (suite *UserStandardTestSuite) SetupTest() { suite.db = testrig.NewTestDB(&suite.state) suite.state.DB = suite.db suite.state.AdminActions = admin.New(suite.state.DB, &suite.state.Workers) + suite.oauthServer = testrig.NewTestOauthServer(suite.state.DB) suite.sentEmails = make(map[string]string) suite.emailSender = testrig.NewEmailSender("../../../web/template/", suite.sentEmails) + suite.testApps = testrig.NewTestApplications() + suite.testTokens = testrig.NewTestTokens() suite.testUsers = testrig.NewTestUsers() suite.user = user.New(&suite.state, typeutils.NewConverter(&suite.state), testrig.NewTestOauthServer(suite.db), suite.emailSender) From 787bdc1488da476e54fb0daded061cf36ecf9010 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:46:36 +0100 Subject: [PATCH 09/14] [feature] make account sign-up / backlog limits configurable (#3768) --- docs/admin/signups.md | 6 ++-- docs/configuration/accounts.md | 22 +++++++++++++ example/config.yaml | 22 +++++++++++++ internal/config/config.go | 10 +++--- internal/config/defaults.go | 10 +++--- internal/config/helpers.gen.go | 50 ++++++++++++++++++++++++++++ internal/processing/user/create.go | 53 +++++++++++++++++------------- test/envparsing.sh | 4 +++ testrig/config.go | 10 +++--- 9 files changed, 151 insertions(+), 36 deletions(-) diff --git a/docs/admin/signups.md b/docs/admin/signups.md index 78513380c..896059be9 100644 --- a/docs/admin/signups.md +++ b/docs/admin/signups.md @@ -46,12 +46,14 @@ If you **reject** the sign-up, you may wish to inform the applicant that their s ## Sign-Up Limits -To avoid sign-up backlogs overwhelming admins and moderators, GoToSocial limits the sign-up pending backlog to 20 accounts. Once there are 20 accounts pending in the backlog waiting to be handled by an admin or moderator, new sign-ups will not be accepted via the form. +By default, to avoid sign-up backlogs overwhelming admins and moderators, GoToSocial limits the sign-up pending backlog to 20 accounts. Once there are 20 accounts pending in the backlog waiting to be handled by an admin or moderator, new sign-ups will not be accepted via the form. -New sign-ups will also not be accepted via the form if 10 or more new account sign-ups have been approved in the last 24 hours, to avoid instances rapidly expanding beyond the capabilities of moderators. +By default, new sign-ups will also not be accepted via the form if 10 or more new account sign-ups have been approved in the last 24 hours, to avoid instances rapidly expanding beyond the capabilities of moderators. In both cases, applicants will be shown an error message explaining why they could not submit the form, and inviting them to try again later. +The limit of sign-ups per day, and the backlog size, can be configured or disabled altogether with the variables `accounts-registration-daily-limit` and `accounts-registration-backlog-limit`. See the [accounts config section](../configuration/accounts.md) for more info. + To combat spam accounts, GoToSocial account sign-ups **always** require manual approval by an administrator, and applicants must **always** confirm their email address before they are able to log in and post. ## Sign-Up Via Invite diff --git a/docs/configuration/accounts.md b/docs/configuration/accounts.md index 41fb3eaa9..788cf79ac 100644 --- a/docs/configuration/accounts.md +++ b/docs/configuration/accounts.md @@ -20,6 +20,28 @@ accounts-registration-open: false # Default: true accounts-reason-required: true +# Int. Number of approved sign-ups allowed within +# 24hrs before new account registration is closed. +# +# Leaving this count at the default essentially limits +# your instance to growing by 10 accounts per day. +# +# Setting this number to 0 or less removes the limit. +# +# Default: 10 +accounts-registration-daily-limit: 10 + +# Int. Number of new account sign-ups allowed in the pending +# approval queue before new account registration is closed. +# +# This can be used to essentially "throttle" the sign-up +# queue to prevent instance admins becoming overwhelmed. +# +# Setting this number to 0 or less removes the limit. +# +# Default: 20 +accounts-registration-backlog-limit: 20 + # Bool. Allow accounts on this instance to set custom CSS for their profile pages and statuses. # Enabling this setting will allow accounts to upload custom CSS via the /user settings page, # which will then be rendered on the web view of the account's profile and statuses. diff --git a/example/config.yaml b/example/config.yaml index 60d56bafc..b618ad7ba 100644 --- a/example/config.yaml +++ b/example/config.yaml @@ -475,6 +475,28 @@ accounts-registration-open: false # Default: true accounts-reason-required: true +# Int. Number of approved sign-ups allowed within +# 24hrs before new account registration is closed. +# +# Leaving this count at the default essentially limits +# your instance to growing by 10 accounts per day. +# +# Setting this number to 0 or less removes the limit. +# +# Default: 10 +accounts-registration-daily-limit: 10 + +# Int. Number of new account sign-ups allowed in the pending +# approval queue before new account registration is closed. +# +# This can be used to essentially "throttle" the sign-up +# queue to prevent instance admins becoming overwhelmed. +# +# Setting this number to 0 or less removes the limit. +# +# Default: 20 +accounts-registration-backlog-limit: 20 + # Bool. Allow accounts on this instance to set custom CSS for their profile pages and statuses. # Enabling this setting will allow accounts to upload custom CSS via the /user settings page, # which will then be rendered on the web view of the account's profile and statuses. diff --git a/internal/config/config.go b/internal/config/config.go index 5c59c47cc..33003d0f9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -92,10 +92,12 @@ type Configuration struct { InstanceSubscriptionsProcessEvery time.Duration `name:"instance-subscriptions-process-every" usage:"Period to elapse between instance subscriptions processing jobs, starting from instance-subscriptions-process-from."` InstanceStatsMode string `name:"instance-stats-mode" usage:"Allows you to customize the way stats are served to crawlers: one of '', 'serve', 'zero', 'baffle'. Home page stats remain unchanged."` - AccountsRegistrationOpen bool `name:"accounts-registration-open" usage:"Allow anyone to submit an account signup request. If false, server will be invite-only."` - AccountsReasonRequired bool `name:"accounts-reason-required" usage:"Do new account signups require a reason to be submitted on registration?"` - AccountsAllowCustomCSS bool `name:"accounts-allow-custom-css" usage:"Allow accounts to enable custom CSS for their profile pages and statuses."` - AccountsCustomCSSLength int `name:"accounts-custom-css-length" usage:"Maximum permitted length (characters) of custom CSS for accounts."` + AccountsRegistrationOpen bool `name:"accounts-registration-open" usage:"Allow anyone to submit an account signup request. If false, server will be invite-only."` + AccountsReasonRequired bool `name:"accounts-reason-required" usage:"Do new account signups require a reason to be submitted on registration?"` + AccountsRegistrationDailyLimit int `name:"accounts-registration-daily-limit" usage:"Limit amount of approved account sign-ups allowed per 24hrs before registration is closed. 0 or less = no limit."` + AccountsRegistrationBacklogLimit int `name:"accounts-registration-backlog-limit" usage:"Limit how big the 'accounts pending approval' queue can grow before registration is closed. 0 or less = no limit."` + AccountsAllowCustomCSS bool `name:"accounts-allow-custom-css" usage:"Allow accounts to enable custom CSS for their profile pages and statuses."` + AccountsCustomCSSLength int `name:"accounts-custom-css-length" usage:"Maximum permitted length (characters) of custom CSS for accounts."` MediaDescriptionMinChars int `name:"media-description-min-chars" usage:"Min required chars for an image description"` MediaDescriptionMaxChars int `name:"media-description-max-chars" usage:"Max permitted chars for an image description"` diff --git a/internal/config/defaults.go b/internal/config/defaults.go index 157dfde0a..7f66e4209 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -68,10 +68,12 @@ var Defaults = Configuration{ InstanceSubscriptionsProcessFrom: "23:00", // 11pm, InstanceSubscriptionsProcessEvery: 24 * time.Hour, // 1/day. - AccountsRegistrationOpen: false, - AccountsReasonRequired: true, - AccountsAllowCustomCSS: false, - AccountsCustomCSSLength: 10000, + AccountsRegistrationOpen: false, + AccountsReasonRequired: true, + AccountsRegistrationDailyLimit: 10, + AccountsRegistrationBacklogLimit: 20, + AccountsAllowCustomCSS: false, + AccountsCustomCSSLength: 10000, MediaDescriptionMinChars: 0, MediaDescriptionMaxChars: 1500, diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index 54d1b62d9..d3ccf16ea 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -1132,6 +1132,56 @@ func GetAccountsReasonRequired() bool { return global.GetAccountsReasonRequired( // SetAccountsReasonRequired safely sets the value for global configuration 'AccountsReasonRequired' field func SetAccountsReasonRequired(v bool) { global.SetAccountsReasonRequired(v) } +// GetAccountsRegistrationDailyLimit safely fetches the Configuration value for state's 'AccountsRegistrationDailyLimit' field +func (st *ConfigState) GetAccountsRegistrationDailyLimit() (v int) { + st.mutex.RLock() + v = st.config.AccountsRegistrationDailyLimit + st.mutex.RUnlock() + return +} + +// SetAccountsRegistrationDailyLimit safely sets the Configuration value for state's 'AccountsRegistrationDailyLimit' field +func (st *ConfigState) SetAccountsRegistrationDailyLimit(v int) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.AccountsRegistrationDailyLimit = v + st.reloadToViper() +} + +// AccountsRegistrationDailyLimitFlag returns the flag name for the 'AccountsRegistrationDailyLimit' field +func AccountsRegistrationDailyLimitFlag() string { return "accounts-registration-daily-limit" } + +// GetAccountsRegistrationDailyLimit safely fetches the value for global configuration 'AccountsRegistrationDailyLimit' field +func GetAccountsRegistrationDailyLimit() int { return global.GetAccountsRegistrationDailyLimit() } + +// SetAccountsRegistrationDailyLimit safely sets the value for global configuration 'AccountsRegistrationDailyLimit' field +func SetAccountsRegistrationDailyLimit(v int) { global.SetAccountsRegistrationDailyLimit(v) } + +// GetAccountsRegistrationBacklogLimit safely fetches the Configuration value for state's 'AccountsRegistrationBacklogLimit' field +func (st *ConfigState) GetAccountsRegistrationBacklogLimit() (v int) { + st.mutex.RLock() + v = st.config.AccountsRegistrationBacklogLimit + st.mutex.RUnlock() + return +} + +// SetAccountsRegistrationBacklogLimit safely sets the Configuration value for state's 'AccountsRegistrationBacklogLimit' field +func (st *ConfigState) SetAccountsRegistrationBacklogLimit(v int) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.AccountsRegistrationBacklogLimit = v + st.reloadToViper() +} + +// AccountsRegistrationBacklogLimitFlag returns the flag name for the 'AccountsRegistrationBacklogLimit' field +func AccountsRegistrationBacklogLimitFlag() string { return "accounts-registration-backlog-limit" } + +// GetAccountsRegistrationBacklogLimit safely fetches the value for global configuration 'AccountsRegistrationBacklogLimit' field +func GetAccountsRegistrationBacklogLimit() int { return global.GetAccountsRegistrationBacklogLimit() } + +// SetAccountsRegistrationBacklogLimit safely sets the value for global configuration 'AccountsRegistrationBacklogLimit' field +func SetAccountsRegistrationBacklogLimit(v int) { global.SetAccountsRegistrationBacklogLimit(v) } + // GetAccountsAllowCustomCSS safely fetches the Configuration value for state's 'AccountsAllowCustomCSS' field func (st *ConfigState) GetAccountsAllowCustomCSS() (v bool) { st.mutex.RLock() diff --git a/internal/processing/user/create.go b/internal/processing/user/create.go index 0d848583e..f878d8320 100644 --- a/internal/processing/user/create.go +++ b/internal/processing/user/create.go @@ -44,34 +44,43 @@ func (p *Processor) Create( app *gtsmodel.Application, form *apimodel.AccountCreateRequest, ) (*gtsmodel.User, gtserror.WithCode) { - const ( - usersPerDay = 10 - regBacklog = 20 + var ( + usersPerDay = config.GetAccountsRegistrationDailyLimit() + regBacklog = config.GetAccountsRegistrationBacklogLimit() ) - // Ensure no more than usersPerDay + // If usersPerDay limit is in place, + // ensure no more than usersPerDay // have registered in the last 24h. - newUsersCount, err := p.state.DB.CountApprovedSignupsSince(ctx, time.Now().Add(-24*time.Hour)) - if err != nil { - err := fmt.Errorf("db error counting new users: %w", err) - return nil, gtserror.NewErrorInternalError(err) + if usersPerDay > 0 { + newUsersCount, err := p.state.DB.CountApprovedSignupsSince(ctx, time.Now().Add(-24*time.Hour)) + if err != nil { + err := fmt.Errorf("db error counting new users: %w", err) + return nil, gtserror.NewErrorInternalError(err) + } + + if newUsersCount >= usersPerDay { + err := fmt.Errorf("this instance has hit its limit of new sign-ups for today (%d); you can try again tomorrow", usersPerDay) + return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error()) + } } - if newUsersCount >= usersPerDay { - err := fmt.Errorf("this instance has hit its limit of new sign-ups for today; you can try again tomorrow") - return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error()) - } + // If registration backlog limit is + // in place, ensure backlog isn't full. + if regBacklog > 0 { + backlogLen, err := p.state.DB.CountUnhandledSignups(ctx) + if err != nil { + err := fmt.Errorf("db error counting registration backlog length: %w", err) + return nil, gtserror.NewErrorInternalError(err) + } - // Ensure the new users backlog isn't full. - backlogLen, err := p.state.DB.CountUnhandledSignups(ctx) - if err != nil { - err := fmt.Errorf("db error counting registration backlog length: %w", err) - return nil, gtserror.NewErrorInternalError(err) - } - - if backlogLen >= regBacklog { - err := fmt.Errorf("this instance's sign-up backlog is currently full; you must wait until pending sign-ups are handled by the admin(s)") - return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error()) + if backlogLen >= regBacklog { + err := fmt.Errorf( + "this instance's sign-up backlog is currently full (%d sign-ups pending approval); "+ + "you must wait until some pending sign-ups are handled by the admin(s)", regBacklog, + ) + return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error()) + } } emailAvailable, err := p.state.DB.IsEmailAvailable(ctx, form.Email) diff --git a/test/envparsing.sh b/test/envparsing.sh index 904dc8764..0e7c0db20 100755 --- a/test/envparsing.sh +++ b/test/envparsing.sh @@ -8,6 +8,8 @@ EXPECT=$(cat << "EOF" "accounts-allow-custom-css": true, "accounts-custom-css-length": 5000, "accounts-reason-required": false, + "accounts-registration-backlog-limit": 100, + "accounts-registration-daily-limit": 50, "accounts-registration-open": true, "advanced-cookies-samesite": "strict", "advanced-csp-extra-uris": [], @@ -252,6 +254,8 @@ GTS_INSTANCE_LANGUAGES="nl,en-gb" \ GTS_INSTANCE_STATS_MODE="baffle" \ GTS_ACCOUNTS_ALLOW_CUSTOM_CSS=true \ GTS_ACCOUNTS_CUSTOM_CSS_LENGTH=5000 \ +GTS_ACCOUNTS_REGISTRATION_BACKLOG_LIMIT=100 \ +GTS_ACCOUNTS_REGISTRATION_DAILY_LIMIT=50 \ GTS_ACCOUNTS_REGISTRATION_OPEN=true \ GTS_ACCOUNTS_REASON_REQUIRED=false \ GTS_MEDIA_DESCRIPTION_MIN_CHARS=69 \ diff --git a/testrig/config.go b/testrig/config.go index 0a957a831..f68a8ffb7 100644 --- a/testrig/config.go +++ b/testrig/config.go @@ -102,10 +102,12 @@ func testDefaults() config.Configuration { InstanceSubscriptionsProcessFrom: "23:00", // 11pm, InstanceSubscriptionsProcessEvery: 24 * time.Hour, // 1/day. - AccountsRegistrationOpen: true, - AccountsReasonRequired: true, - AccountsAllowCustomCSS: true, - AccountsCustomCSSLength: 10000, + AccountsRegistrationOpen: true, + AccountsReasonRequired: true, + AccountsRegistrationDailyLimit: 10, + AccountsRegistrationBacklogLimit: 20, + AccountsAllowCustomCSS: true, + AccountsCustomCSSLength: 10000, MediaDescriptionMinChars: 0, MediaDescriptionMaxChars: 500, From edcc8ea4ed0915922bf6e262507ede6d8325ad02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:47:00 +0100 Subject: [PATCH 10/14] [chore]: Bump golang.org/x/oauth2 from 0.25.0 to 0.26.0 (#3775) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.25.0 to 0.26.0. - [Commits](https://github.com/golang/oauth2/compare/v0.25.0...v0.26.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 4 ++-- vendor/modules.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 6dd3cf15f..61031ce01 100644 --- a/go.mod +++ b/go.mod @@ -81,7 +81,8 @@ require ( golang.org/x/crypto v0.32.0 golang.org/x/image v0.23.0 golang.org/x/net v0.34.0 - golang.org/x/oauth2 v0.25.0 + golang.org/x/oauth2 v0.26.0 + golang.org/x/sys v0.29.0 golang.org/x/text v0.21.0 gopkg.in/mcuadros/go-syslog.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.1 @@ -212,7 +213,6 @@ require ( golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.22.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.29.0 // indirect golang.org/x/tools v0.28.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect diff --git a/go.sum b/go.sum index f002811e8..40212d2fe 100644 --- a/go.sum +++ b/go.sum @@ -753,8 +753,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= -golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE= +golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/vendor/modules.txt b/vendor/modules.txt index ae45c7578..b0bfd907b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1107,7 +1107,7 @@ golang.org/x/net/ipv4 golang.org/x/net/ipv6 golang.org/x/net/publicsuffix golang.org/x/net/trace -# golang.org/x/oauth2 v0.25.0 +# golang.org/x/oauth2 v0.26.0 ## explicit; go 1.18 golang.org/x/oauth2 golang.org/x/oauth2/internal From 576da4cf01f9a739804d38c9cdda0a063a674359 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:10:30 +0000 Subject: [PATCH 11/14] [chore]: Bump golang.org/x/image from 0.23.0 to 0.24.0 (#3773) --- go.mod | 6 +++--- go.sum | 10 ++++++---- vendor/golang.org/x/sync/errgroup/errgroup.go | 1 + vendor/modules.txt | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 61031ce01..a54749102 100644 --- a/go.mod +++ b/go.mod @@ -79,11 +79,11 @@ require ( go.opentelemetry.io/otel/trace v1.34.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/crypto v0.32.0 - golang.org/x/image v0.23.0 + golang.org/x/image v0.24.0 golang.org/x/net v0.34.0 golang.org/x/oauth2 v0.26.0 golang.org/x/sys v0.29.0 - golang.org/x/text v0.21.0 + golang.org/x/text v0.22.0 gopkg.in/mcuadros/go-syslog.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.1 modernc.org/sqlite v0.0.0-00010101000000-000000000000 @@ -212,7 +212,7 @@ require ( golang.org/x/arch v0.13.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.22.0 // indirect - golang.org/x/sync v0.10.0 // indirect + golang.org/x/sync v0.11.0 // indirect golang.org/x/tools v0.28.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect diff --git a/go.sum b/go.sum index 40212d2fe..d19b2b932 100644 --- a/go.sum +++ b/go.sum @@ -681,8 +681,8 @@ golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUF golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68= -golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= +golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ= +golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -768,8 +768,9 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -840,8 +841,9 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go index 948a3ee63..b8322598a 100644 --- a/vendor/golang.org/x/sync/errgroup/errgroup.go +++ b/vendor/golang.org/x/sync/errgroup/errgroup.go @@ -118,6 +118,7 @@ func (g *Group) TryGo(f func() error) bool { // SetLimit limits the number of active goroutines in this group to at most n. // A negative value indicates no limit. +// A limit of zero will prevent any new goroutines from being added. // // Any subsequent call to the Go method will block until it can add an active // goroutine without exceeding the configured limit. diff --git a/vendor/modules.txt b/vendor/modules.txt index b0bfd907b..033080571 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1078,7 +1078,7 @@ golang.org/x/exp/slices golang.org/x/exp/slog golang.org/x/exp/slog/internal golang.org/x/exp/slog/internal/buffer -# golang.org/x/image v0.23.0 +# golang.org/x/image v0.24.0 ## explicit; go 1.18 golang.org/x/image/riff golang.org/x/image/vp8 @@ -1111,7 +1111,7 @@ golang.org/x/net/trace ## explicit; go 1.18 golang.org/x/oauth2 golang.org/x/oauth2/internal -# golang.org/x/sync v0.10.0 +# golang.org/x/sync v0.11.0 ## explicit; go 1.18 golang.org/x/sync/errgroup golang.org/x/sync/semaphore @@ -1121,7 +1121,7 @@ golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows golang.org/x/sys/windows/registry -# golang.org/x/text v0.21.0 +# golang.org/x/text v0.22.0 ## explicit; go 1.18 golang.org/x/text/cases golang.org/x/text/encoding From bb6d2f8ee8db01794c03dad2ef96905ffe76f9ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:30:29 +0000 Subject: [PATCH 12/14] [chore]: Bump github.com/minio/minio-go/v7 from 7.0.84 to 7.0.85 (#3772) --- go.mod | 2 +- go.sum | 4 +- .../minio/minio-go/v7/api-remove.go | 8 ++++ vendor/github.com/minio/minio-go/v7/api.go | 40 ++++++++++++++++++- .../minio/minio-go/v7/s3-endpoints.go | 12 ++++++ vendor/modules.txt | 2 +- 6 files changed, 62 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index a54749102..48f5af898 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/k3a/html2text v1.2.1 github.com/microcosm-cc/bluemonday v1.0.27 github.com/miekg/dns v1.1.63 - github.com/minio/minio-go/v7 v7.0.84 + github.com/minio/minio-go/v7 v7.0.85 github.com/mitchellh/mapstructure v1.5.0 github.com/ncruces/go-sqlite3 v0.22.0 github.com/oklog/ulid v1.3.1 diff --git a/go.sum b/go.sum index d19b2b932..2a38160d6 100644 --- a/go.sum +++ b/go.sum @@ -403,8 +403,8 @@ github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY= github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.84 h1:D1HVmAF8JF8Bpi6IU4V9vIEj+8pc+xU88EWMs2yed0E= -github.com/minio/minio-go/v7 v7.0.84/go.mod h1:57YXpvc5l3rjPdhqNrDsvVlY0qPI6UTk1bflAe+9doY= +github.com/minio/minio-go/v7 v7.0.85 h1:9psTLS/NTvC3MWoyjhjXpwcKoNbkongaCSF3PNpSuXo= +github.com/minio/minio-go/v7 v7.0.85/go.mod h1:57YXpvc5l3rjPdhqNrDsvVlY0qPI6UTk1bflAe+9doY= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= diff --git a/vendor/github.com/minio/minio-go/v7/api-remove.go b/vendor/github.com/minio/minio-go/v7/api-remove.go index d2e932923..523431351 100644 --- a/vendor/github.com/minio/minio-go/v7/api-remove.go +++ b/vendor/github.com/minio/minio-go/v7/api-remove.go @@ -213,6 +213,14 @@ type RemoveObjectError struct { Err error } +func (err *RemoveObjectError) Error() string { + // This should never happen as we will have a non-nil error with no underlying error. + if err.Err == nil { + return "unexpected remove object error result" + } + return err.Err.Error() +} + // RemoveObjectResult - container of Multi Delete S3 API result type RemoveObjectResult struct { ObjectName string diff --git a/vendor/github.com/minio/minio-go/v7/api.go b/vendor/github.com/minio/minio-go/v7/api.go index cc0ded2c7..ff9f69118 100644 --- a/vendor/github.com/minio/minio-go/v7/api.go +++ b/vendor/github.com/minio/minio-go/v7/api.go @@ -92,6 +92,9 @@ type Client struct { // default to Auto. lookup BucketLookupType + // lookupFn is a custom function to return URL lookup type supported by the server. + lookupFn func(u url.URL, bucketName string) BucketLookupType + // Factory for MD5 hash functions. md5Hasher func() md5simd.Hasher sha256Hasher func() md5simd.Hasher @@ -117,6 +120,25 @@ type Options struct { // function to perform region lookups appropriately. CustomRegionViaURL func(u url.URL) string + // Provide a custom function that returns BucketLookupType based + // on the input URL, this is just like s3utils.IsVirtualHostSupported() + // function but allows users to provide their own implementation. + // Once this is set it overrides all settings for opts.BucketLookup + // if this function returns BucketLookupAuto then default detection + // via s3utils.IsVirtualHostSupported() is used, otherwise the + // function is expected to return appropriate value as expected for + // the URL the user wishes to honor. + // + // BucketName is passed additionally for the caller to ensure + // handle situations where `bucketNames` have multiple `.` separators + // in such case HTTPs certs will not work properly for *. + // wildcards, so you need to specifically handle these situations + // and not return bucket as part of DNS since those requests may fail. + // + // For better understanding look at s3utils.IsVirtualHostSupported() + // implementation. + BucketLookupViaURL func(u url.URL, bucketName string) BucketLookupType + // TrailingHeaders indicates server support of trailing headers. // Only supported for v4 signatures. TrailingHeaders bool @@ -133,7 +155,7 @@ type Options struct { // Global constants. const ( libraryName = "minio-go" - libraryVersion = "v7.0.84" + libraryVersion = "v7.0.85" ) // User Agent should always following the below style. @@ -279,6 +301,7 @@ func privateNew(endpoint string, opts *Options) (*Client, error) { // Sets bucket lookup style, whether server accepts DNS or Path lookup. Default is Auto - determined // by the SDK. When Auto is specified, DNS lookup is used for Amazon/Google cloud endpoints and Path for all other endpoints. clnt.lookup = opts.BucketLookup + clnt.lookupFn = opts.BucketLookupViaURL // healthcheck is not initialized clnt.healthStatus = unknown @@ -1003,6 +1026,18 @@ func (c *Client) makeTargetURL(bucketName, objectName, bucketLocation string, is // returns true if virtual hosted style requests are to be used. func (c *Client) isVirtualHostStyleRequest(url url.URL, bucketName string) bool { + if c.lookupFn != nil { + lookup := c.lookupFn(url, bucketName) + switch lookup { + case BucketLookupDNS: + return true + case BucketLookupPath: + return false + } + // if its auto then we fallback to default detection. + return s3utils.IsVirtualHostSupported(url, bucketName) + } + if bucketName == "" { return false } @@ -1010,11 +1045,12 @@ func (c *Client) isVirtualHostStyleRequest(url url.URL, bucketName string) bool if c.lookup == BucketLookupDNS { return true } + if c.lookup == BucketLookupPath { return false } - // default to virtual only for Amazon/Google storage. In all other cases use + // default to virtual only for Amazon/Google storage. In all other cases use // path style requests return s3utils.IsVirtualHostSupported(url, bucketName) } diff --git a/vendor/github.com/minio/minio-go/v7/s3-endpoints.go b/vendor/github.com/minio/minio-go/v7/s3-endpoints.go index 01cee8a19..baab23e96 100644 --- a/vendor/github.com/minio/minio-go/v7/s3-endpoints.go +++ b/vendor/github.com/minio/minio-go/v7/s3-endpoints.go @@ -32,6 +32,18 @@ var awsS3EndpointMap = map[string]awsS3Endpoint{ "s3.us-east-2.amazonaws.com", "s3.dualstack.us-east-2.amazonaws.com", }, + "us-iso-east-1": { + "s3.us-iso-east-1.c2s.ic.gov", + "s3.dualstack.us-iso-east-1.c2s.ic.gov", + }, + "us-isob-east-1": { + "s3.us-isob-east-1.sc2s.sgov.gov", + "s3.dualstack.us-isob-east-1.sc2s.sgov.gov", + }, + "us-iso-west-1": { + "s3.us-iso-west-1.c2s.ic.gov", + "s3.dualstack.us-iso-west-1.c2s.ic.gov", + }, "us-west-2": { "s3.us-west-2.amazonaws.com", "s3.dualstack.us-west-2.amazonaws.com", diff --git a/vendor/modules.txt b/vendor/modules.txt index 033080571..73d9ee847 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -469,7 +469,7 @@ github.com/miekg/dns # github.com/minio/md5-simd v1.1.2 ## explicit; go 1.14 github.com/minio/md5-simd -# github.com/minio/minio-go/v7 v7.0.84 +# github.com/minio/minio-go/v7 v7.0.85 ## explicit; go 1.22 github.com/minio/minio-go/v7 github.com/minio/minio-go/v7/pkg/cors From 4ac5447ad61f9afc73b542d9d6eb36e29fd79af4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:52:55 +0000 Subject: [PATCH 13/14] [chore]: Bump golang.org/x/crypto from 0.32.0 to 0.33.0 (#3771) --- go.mod | 4 +- go.sum | 12 +- vendor/golang.org/x/crypto/acme/acme.go | 6 +- vendor/golang.org/x/crypto/acme/types.go | 11 ++ vendor/golang.org/x/crypto/ssh/handshake.go | 14 ++- vendor/golang.org/x/crypto/ssh/server.go | 50 ++++++-- vendor/golang.org/x/sys/cpu/cpu.go | 3 + vendor/golang.org/x/sys/cpu/cpu_x86.go | 21 +++- vendor/golang.org/x/sys/unix/auxv.go | 36 ++++++ .../golang.org/x/sys/unix/auxv_unsupported.go | 13 ++ .../golang.org/x/sys/unix/syscall_solaris.go | 87 +++++++++++++ vendor/golang.org/x/sys/unix/zerrors_linux.go | 20 ++- .../x/sys/unix/zerrors_linux_386.go | 3 + .../x/sys/unix/zerrors_linux_amd64.go | 3 + .../x/sys/unix/zerrors_linux_arm.go | 3 + .../x/sys/unix/zerrors_linux_arm64.go | 4 + .../x/sys/unix/zerrors_linux_loong64.go | 3 + .../x/sys/unix/zerrors_linux_mips.go | 3 + .../x/sys/unix/zerrors_linux_mips64.go | 3 + .../x/sys/unix/zerrors_linux_mips64le.go | 3 + .../x/sys/unix/zerrors_linux_mipsle.go | 3 + .../x/sys/unix/zerrors_linux_ppc.go | 3 + .../x/sys/unix/zerrors_linux_ppc64.go | 3 + .../x/sys/unix/zerrors_linux_ppc64le.go | 3 + .../x/sys/unix/zerrors_linux_riscv64.go | 3 + .../x/sys/unix/zerrors_linux_s390x.go | 3 + .../x/sys/unix/zerrors_linux_sparc64.go | 3 + .../x/sys/unix/zsyscall_solaris_amd64.go | 114 ++++++++++++++++++ .../x/sys/unix/zsysnum_linux_386.go | 4 + .../x/sys/unix/zsysnum_linux_amd64.go | 4 + .../x/sys/unix/zsysnum_linux_arm.go | 4 + .../x/sys/unix/zsysnum_linux_arm64.go | 4 + .../x/sys/unix/zsysnum_linux_loong64.go | 4 + .../x/sys/unix/zsysnum_linux_mips.go | 4 + .../x/sys/unix/zsysnum_linux_mips64.go | 4 + .../x/sys/unix/zsysnum_linux_mips64le.go | 4 + .../x/sys/unix/zsysnum_linux_mipsle.go | 4 + .../x/sys/unix/zsysnum_linux_ppc.go | 4 + .../x/sys/unix/zsysnum_linux_ppc64.go | 4 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 4 + .../x/sys/unix/zsysnum_linux_riscv64.go | 4 + .../x/sys/unix/zsysnum_linux_s390x.go | 4 + .../x/sys/unix/zsysnum_linux_sparc64.go | 4 + vendor/golang.org/x/sys/unix/ztypes_linux.go | 6 +- vendor/modules.txt | 4 +- 45 files changed, 474 insertions(+), 33 deletions(-) create mode 100644 vendor/golang.org/x/sys/unix/auxv.go create mode 100644 vendor/golang.org/x/sys/unix/auxv_unsupported.go diff --git a/go.mod b/go.mod index 48f5af898..59c924a09 100644 --- a/go.mod +++ b/go.mod @@ -78,11 +78,11 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.34.0 go.opentelemetry.io/otel/trace v1.34.0 go.uber.org/automaxprocs v1.6.0 - golang.org/x/crypto v0.32.0 + golang.org/x/crypto v0.33.0 golang.org/x/image v0.24.0 golang.org/x/net v0.34.0 golang.org/x/oauth2 v0.26.0 - golang.org/x/sys v0.29.0 + golang.org/x/sys v0.30.0 golang.org/x/text v0.22.0 gopkg.in/mcuadros/go-syslog.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 2a38160d6..3a1613c89 100644 --- a/go.sum +++ b/go.sum @@ -665,8 +665,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= -golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -815,8 +815,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -827,8 +827,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= -golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/vendor/golang.org/x/crypto/acme/acme.go b/vendor/golang.org/x/crypto/acme/acme.go index aaafea2bc..a43c62f1d 100644 --- a/vendor/golang.org/x/crypto/acme/acme.go +++ b/vendor/golang.org/x/crypto/acme/acme.go @@ -514,7 +514,11 @@ func (c *Client) Accept(ctx context.Context, chal *Challenge) (*Challenge, error return nil, err } - res, err := c.post(ctx, nil, chal.URI, json.RawMessage("{}"), wantStatus( + payload := json.RawMessage("{}") + if len(chal.Payload) != 0 { + payload = chal.Payload + } + res, err := c.post(ctx, nil, chal.URI, payload, wantStatus( http.StatusOK, // according to the spec http.StatusAccepted, // Let's Encrypt: see https://goo.gl/WsJ7VT (acme-divergences.md) )) diff --git a/vendor/golang.org/x/crypto/acme/types.go b/vendor/golang.org/x/crypto/acme/types.go index 23a4d6517..45492adc8 100644 --- a/vendor/golang.org/x/crypto/acme/types.go +++ b/vendor/golang.org/x/crypto/acme/types.go @@ -7,6 +7,7 @@ package acme import ( "crypto" "crypto/x509" + "encoding/json" "errors" "fmt" "net/http" @@ -527,6 +528,16 @@ type Challenge struct { // when this challenge was used. // The type of a non-nil value is *Error. Error error + + // Payload is the JSON-formatted payload that the client sends + // to the server to indicate it is ready to respond to the challenge. + // When unset, it defaults to an empty JSON object: {}. + // For most challenges, the client must not set Payload, + // see https://tools.ietf.org/html/rfc8555#section-7.5.1. + // Payload is used only for newer challenges (such as "device-attest-01") + // where the client must send additional data for the server to validate + // the challenge. + Payload json.RawMessage } // wireChallenge is ACME JSON challenge representation. diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go index 56cdc7c21..fef687db0 100644 --- a/vendor/golang.org/x/crypto/ssh/handshake.go +++ b/vendor/golang.org/x/crypto/ssh/handshake.go @@ -80,6 +80,7 @@ type handshakeTransport struct { pendingPackets [][]byte // Used when a key exchange is in progress. writePacketsLeft uint32 writeBytesLeft int64 + userAuthComplete bool // whether the user authentication phase is complete // If the read loop wants to schedule a kex, it pings this // channel, and the write loop will send out a kex @@ -552,16 +553,25 @@ func (t *handshakeTransport) sendKexInit() error { return nil } +var errSendBannerPhase = errors.New("ssh: SendAuthBanner outside of authentication phase") + func (t *handshakeTransport) writePacket(p []byte) error { + t.mu.Lock() + defer t.mu.Unlock() + switch p[0] { case msgKexInit: return errors.New("ssh: only handshakeTransport can send kexInit") case msgNewKeys: return errors.New("ssh: only handshakeTransport can send newKeys") + case msgUserAuthBanner: + if t.userAuthComplete { + return errSendBannerPhase + } + case msgUserAuthSuccess: + t.userAuthComplete = true } - t.mu.Lock() - defer t.mu.Unlock() if t.writeError != nil { return t.writeError } diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index 5b5ccd96f..1839ddc6a 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -59,6 +59,27 @@ type GSSAPIWithMICConfig struct { Server GSSAPIServer } +// SendAuthBanner implements [ServerPreAuthConn]. +func (s *connection) SendAuthBanner(msg string) error { + return s.transport.writePacket(Marshal(&userAuthBannerMsg{ + Message: msg, + })) +} + +func (*connection) unexportedMethodForFutureProofing() {} + +// ServerPreAuthConn is the interface available on an incoming server +// connection before authentication has completed. +type ServerPreAuthConn interface { + unexportedMethodForFutureProofing() // permits growing ServerPreAuthConn safely later, ala testing.TB + + ConnMetadata + + // SendAuthBanner sends a banner message to the client. + // It returns an error once the authentication phase has ended. + SendAuthBanner(string) error +} + // ServerConfig holds server specific configuration data. type ServerConfig struct { // Config contains configuration shared between client and server. @@ -118,6 +139,12 @@ type ServerConfig struct { // attempts. AuthLogCallback func(conn ConnMetadata, method string, err error) + // PreAuthConnCallback, if non-nil, is called upon receiving a new connection + // before any authentication has started. The provided ServerPreAuthConn + // can be used at any time before authentication is complete, including + // after this callback has returned. + PreAuthConnCallback func(ServerPreAuthConn) + // ServerVersion is the version identification string to announce in // the public handshake. // If empty, a reasonable default is used. @@ -488,6 +515,10 @@ func (b *BannerError) Error() string { } func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, error) { + if config.PreAuthConnCallback != nil { + config.PreAuthConnCallback(s) + } + sessionID := s.transport.getSessionID() var cache pubKeyCache var perms *Permissions @@ -495,7 +526,7 @@ func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, err authFailures := 0 noneAuthCount := 0 var authErrs []error - var displayedBanner bool + var calledBannerCallback bool partialSuccessReturned := false // Set the initial authentication callbacks from the config. They can be // changed if a PartialSuccessError is returned. @@ -542,14 +573,10 @@ userAuthLoop: s.user = userAuthReq.User - if !displayedBanner && config.BannerCallback != nil { - displayedBanner = true - msg := config.BannerCallback(s) - if msg != "" { - bannerMsg := &userAuthBannerMsg{ - Message: msg, - } - if err := s.transport.writePacket(Marshal(bannerMsg)); err != nil { + if !calledBannerCallback && config.BannerCallback != nil { + calledBannerCallback = true + if msg := config.BannerCallback(s); msg != "" { + if err := s.SendAuthBanner(msg); err != nil { return nil, err } } @@ -762,10 +789,7 @@ userAuthLoop: var bannerErr *BannerError if errors.As(authErr, &bannerErr) { if bannerErr.Message != "" { - bannerMsg := &userAuthBannerMsg{ - Message: bannerErr.Message, - } - if err := s.transport.writePacket(Marshal(bannerMsg)); err != nil { + if err := s.SendAuthBanner(bannerErr.Message); err != nil { return nil, err } } diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index 02609d5b2..9c105f23a 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -72,6 +72,9 @@ var X86 struct { HasSSSE3 bool // Supplemental streaming SIMD extension 3 HasSSE41 bool // Streaming SIMD extension 4 and 4.1 HasSSE42 bool // Streaming SIMD extension 4 and 4.2 + HasAVXIFMA bool // Advanced vector extension Integer Fused Multiply Add + HasAVXVNNI bool // Advanced vector extension Vector Neural Network Instructions + HasAVXVNNIInt8 bool // Advanced vector extension Vector Neural Network Int8 instructions _ CacheLinePad } diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go index 600a68078..1e642f330 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go @@ -53,6 +53,9 @@ func initOptions() { {Name: "sse41", Feature: &X86.HasSSE41}, {Name: "sse42", Feature: &X86.HasSSE42}, {Name: "ssse3", Feature: &X86.HasSSSE3}, + {Name: "avxifma", Feature: &X86.HasAVXIFMA}, + {Name: "avxvnni", Feature: &X86.HasAVXVNNI}, + {Name: "avxvnniint8", Feature: &X86.HasAVXVNNIInt8}, // These capabilities should always be enabled on amd64: {Name: "sse2", Feature: &X86.HasSSE2, Required: runtime.GOARCH == "amd64"}, @@ -106,7 +109,7 @@ func archInit() { return } - _, ebx7, ecx7, edx7 := cpuid(7, 0) + eax7, ebx7, ecx7, edx7 := cpuid(7, 0) X86.HasBMI1 = isSet(3, ebx7) X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX X86.HasBMI2 = isSet(8, ebx7) @@ -134,14 +137,24 @@ func archInit() { X86.HasAVX512VAES = isSet(9, ecx7) X86.HasAVX512VBMI2 = isSet(6, ecx7) X86.HasAVX512BITALG = isSet(12, ecx7) - - eax71, _, _, _ := cpuid(7, 1) - X86.HasAVX512BF16 = isSet(5, eax71) } X86.HasAMXTile = isSet(24, edx7) X86.HasAMXInt8 = isSet(25, edx7) X86.HasAMXBF16 = isSet(22, edx7) + + // These features depend on the second level of extended features. + if eax7 >= 1 { + eax71, _, _, edx71 := cpuid(7, 1) + if X86.HasAVX512 { + X86.HasAVX512BF16 = isSet(5, eax71) + } + if X86.HasAVX { + X86.HasAVXIFMA = isSet(23, eax71) + X86.HasAVXVNNI = isSet(4, eax71) + X86.HasAVXVNNIInt8 = isSet(4, edx71) + } + } } func isSet(bitpos uint, value uint32) bool { diff --git a/vendor/golang.org/x/sys/unix/auxv.go b/vendor/golang.org/x/sys/unix/auxv.go new file mode 100644 index 000000000..37a82528f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/auxv.go @@ -0,0 +1,36 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) + +package unix + +import ( + "syscall" + "unsafe" +) + +//go:linkname runtime_getAuxv runtime.getAuxv +func runtime_getAuxv() []uintptr + +// Auxv returns the ELF auxiliary vector as a sequence of key/value pairs. +// The returned slice is always a fresh copy, owned by the caller. +// It returns an error on non-ELF platforms, or if the auxiliary vector cannot be accessed, +// which happens in some locked-down environments and build modes. +func Auxv() ([][2]uintptr, error) { + vec := runtime_getAuxv() + vecLen := len(vec) + + if vecLen == 0 { + return nil, syscall.ENOENT + } + + if vecLen%2 != 0 { + return nil, syscall.EINVAL + } + + result := make([]uintptr, vecLen) + copy(result, vec) + return unsafe.Slice((*[2]uintptr)(unsafe.Pointer(&result[0])), vecLen/2), nil +} diff --git a/vendor/golang.org/x/sys/unix/auxv_unsupported.go b/vendor/golang.org/x/sys/unix/auxv_unsupported.go new file mode 100644 index 000000000..1200487f2 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/auxv_unsupported.go @@ -0,0 +1,13 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) + +package unix + +import "syscall" + +func Auxv() ([][2]uintptr, error) { + return nil, syscall.ENOTSUP +} diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index 21974af06..abc395547 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -1102,3 +1102,90 @@ func (s *Strioctl) SetInt(i int) { func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) { return ioctlPtrRet(fd, req, unsafe.Pointer(s)) } + +// Ucred Helpers +// See ucred(3c) and getpeerucred(3c) + +//sys getpeerucred(fd uintptr, ucred *uintptr) (err error) +//sys ucredFree(ucred uintptr) = ucred_free +//sys ucredGet(pid int) (ucred uintptr, err error) = ucred_get +//sys ucredGeteuid(ucred uintptr) (uid int) = ucred_geteuid +//sys ucredGetegid(ucred uintptr) (gid int) = ucred_getegid +//sys ucredGetruid(ucred uintptr) (uid int) = ucred_getruid +//sys ucredGetrgid(ucred uintptr) (gid int) = ucred_getrgid +//sys ucredGetsuid(ucred uintptr) (uid int) = ucred_getsuid +//sys ucredGetsgid(ucred uintptr) (gid int) = ucred_getsgid +//sys ucredGetpid(ucred uintptr) (pid int) = ucred_getpid + +// Ucred is an opaque struct that holds user credentials. +type Ucred struct { + ucred uintptr +} + +// We need to ensure that ucredFree is called on the underlying ucred +// when the Ucred is garbage collected. +func ucredFinalizer(u *Ucred) { + ucredFree(u.ucred) +} + +func GetPeerUcred(fd uintptr) (*Ucred, error) { + var ucred uintptr + err := getpeerucred(fd, &ucred) + if err != nil { + return nil, err + } + result := &Ucred{ + ucred: ucred, + } + // set the finalizer on the result so that the ucred will be freed + runtime.SetFinalizer(result, ucredFinalizer) + return result, nil +} + +func UcredGet(pid int) (*Ucred, error) { + ucred, err := ucredGet(pid) + if err != nil { + return nil, err + } + result := &Ucred{ + ucred: ucred, + } + // set the finalizer on the result so that the ucred will be freed + runtime.SetFinalizer(result, ucredFinalizer) + return result, nil +} + +func (u *Ucred) Geteuid() int { + defer runtime.KeepAlive(u) + return ucredGeteuid(u.ucred) +} + +func (u *Ucred) Getruid() int { + defer runtime.KeepAlive(u) + return ucredGetruid(u.ucred) +} + +func (u *Ucred) Getsuid() int { + defer runtime.KeepAlive(u) + return ucredGetsuid(u.ucred) +} + +func (u *Ucred) Getegid() int { + defer runtime.KeepAlive(u) + return ucredGetegid(u.ucred) +} + +func (u *Ucred) Getrgid() int { + defer runtime.KeepAlive(u) + return ucredGetrgid(u.ucred) +} + +func (u *Ucred) Getsgid() int { + defer runtime.KeepAlive(u) + return ucredGetsgid(u.ucred) +} + +func (u *Ucred) Getpid() int { + defer runtime.KeepAlive(u) + return ucredGetpid(u.ucred) +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 6ebc48b3f..4f432bfe8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1245,6 +1245,7 @@ const ( FAN_REPORT_DFID_NAME = 0xc00 FAN_REPORT_DFID_NAME_TARGET = 0x1e00 FAN_REPORT_DIR_FID = 0x400 + FAN_REPORT_FD_ERROR = 0x2000 FAN_REPORT_FID = 0x200 FAN_REPORT_NAME = 0x800 FAN_REPORT_PIDFD = 0x80 @@ -1330,8 +1331,10 @@ const ( FUSE_SUPER_MAGIC = 0x65735546 FUTEXFS_SUPER_MAGIC = 0xbad1dea F_ADD_SEALS = 0x409 + F_CREATED_QUERY = 0x404 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 + F_DUPFD_QUERY = 0x403 F_EXLCK = 0x4 F_GETFD = 0x1 F_GETFL = 0x3 @@ -1551,6 +1554,7 @@ const ( IPPROTO_ROUTING = 0x2b IPPROTO_RSVP = 0x2e IPPROTO_SCTP = 0x84 + IPPROTO_SMC = 0x100 IPPROTO_TCP = 0x6 IPPROTO_TP = 0x1d IPPROTO_UDP = 0x11 @@ -1623,6 +1627,8 @@ const ( IPV6_UNICAST_IF = 0x4c IPV6_USER_FLOW = 0xe IPV6_V6ONLY = 0x1a + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 IPV6_XFRM_POLICY = 0x23 IP_ADD_MEMBERSHIP = 0x23 IP_ADD_SOURCE_MEMBERSHIP = 0x27 @@ -1867,6 +1873,7 @@ const ( MADV_UNMERGEABLE = 0xd MADV_WILLNEED = 0x3 MADV_WIPEONFORK = 0x12 + MAP_DROPPABLE = 0x8 MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 @@ -1967,6 +1974,7 @@ const ( MSG_PEEK = 0x2 MSG_PROXY = 0x10 MSG_RST = 0x1000 + MSG_SOCK_DEVMEM = 0x2000000 MSG_SYN = 0x400 MSG_TRUNC = 0x20 MSG_TRYHARD = 0x4 @@ -2083,6 +2091,7 @@ const ( NFC_ATR_REQ_MAXSIZE = 0x40 NFC_ATR_RES_GB_MAXSIZE = 0x2f NFC_ATR_RES_MAXSIZE = 0x40 + NFC_ATS_MAXSIZE = 0x14 NFC_COMM_ACTIVE = 0x0 NFC_COMM_PASSIVE = 0x1 NFC_DEVICE_NAME_MAXSIZE = 0x8 @@ -2163,6 +2172,7 @@ const ( NFNL_SUBSYS_QUEUE = 0x3 NFNL_SUBSYS_ULOG = 0x4 NFS_SUPER_MAGIC = 0x6969 + NFT_BITWISE_BOOL = 0x0 NFT_CHAIN_FLAGS = 0x7 NFT_CHAIN_MAXNAMELEN = 0x100 NFT_CT_MAX = 0x17 @@ -2491,6 +2501,7 @@ const ( PR_GET_PDEATHSIG = 0x2 PR_GET_SECCOMP = 0x15 PR_GET_SECUREBITS = 0x1b + PR_GET_SHADOW_STACK_STATUS = 0x4a PR_GET_SPECULATION_CTRL = 0x34 PR_GET_TAGGED_ADDR_CTRL = 0x38 PR_GET_THP_DISABLE = 0x2a @@ -2499,6 +2510,7 @@ const ( PR_GET_TIMING = 0xd PR_GET_TSC = 0x19 PR_GET_UNALIGN = 0x5 + PR_LOCK_SHADOW_STACK_STATUS = 0x4c PR_MCE_KILL = 0x21 PR_MCE_KILL_CLEAR = 0x0 PR_MCE_KILL_DEFAULT = 0x2 @@ -2525,6 +2537,8 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PMLEN_MASK = 0x7f000000 + PR_PMLEN_SHIFT = 0x18 PR_PPC_DEXCR_CTRL_CLEAR = 0x4 PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 @@ -2592,6 +2606,7 @@ const ( PR_SET_PTRACER = 0x59616d61 PR_SET_SECCOMP = 0x16 PR_SET_SECUREBITS = 0x1c + PR_SET_SHADOW_STACK_STATUS = 0x4b PR_SET_SPECULATION_CTRL = 0x35 PR_SET_SYSCALL_USER_DISPATCH = 0x3b PR_SET_TAGGED_ADDR_CTRL = 0x37 @@ -2602,6 +2617,9 @@ const ( PR_SET_UNALIGN = 0x6 PR_SET_VMA = 0x53564d41 PR_SET_VMA_ANON_NAME = 0x0 + PR_SHADOW_STACK_ENABLE = 0x1 + PR_SHADOW_STACK_PUSH = 0x4 + PR_SHADOW_STACK_WRITE = 0x2 PR_SME_GET_VL = 0x40 PR_SME_SET_VL = 0x3f PR_SME_SET_VL_ONEXEC = 0x40000 @@ -2911,7 +2929,6 @@ const ( RTM_NEWNEXTHOP = 0x68 RTM_NEWNEXTHOPBUCKET = 0x74 RTM_NEWNSID = 0x58 - RTM_NEWNVLAN = 0x70 RTM_NEWPREFIX = 0x34 RTM_NEWQDISC = 0x24 RTM_NEWROUTE = 0x18 @@ -2920,6 +2937,7 @@ const ( RTM_NEWTCLASS = 0x28 RTM_NEWTFILTER = 0x2c RTM_NEWTUNNEL = 0x78 + RTM_NEWVLAN = 0x70 RTM_NR_FAMILIES = 0x1b RTM_NR_MSGTYPES = 0x6c RTM_SETDCB = 0x4f diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index c0d45e320..75207613c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -116,6 +116,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -304,6 +306,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index c731d24f0..c68acda53 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -116,6 +116,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -305,6 +307,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 680018a4a..a8c607ab8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -310,6 +312,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index a63909f30..18563dd8d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -109,6 +109,7 @@ const ( F_SETOWN = 0x8 F_UNLCK = 0x2 F_WRLCK = 0x1 + GCS_MAGIC = 0x47435300 HIDIOCGRAWINFO = 0x80084803 HIDIOCGRDESC = 0x90044802 HIDIOCGRDESCSIZE = 0x80044801 @@ -119,6 +120,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -302,6 +305,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 9b0a2573f..22912cdaa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -116,6 +116,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -297,6 +299,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index 958e6e064..29344eb37 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -303,6 +305,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 50c7f25bd..20d51fb96 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -303,6 +305,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ced21d66d..321b60902 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -303,6 +305,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 226c04419..9bacdf1e2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -303,6 +305,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 3122737cd..c22427261 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff ISIG = 0x80 IUCLC = 0x1000 IXOFF = 0x400 @@ -358,6 +360,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index eb5d3467e..6270c8ee1 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff ISIG = 0x80 IUCLC = 0x1000 IXOFF = 0x400 @@ -362,6 +364,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index e921ebc60..9966c1941 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x80 IUCLC = 0x1000 IXOFF = 0x400 @@ -362,6 +364,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 38ba81c55..848e5fcc4 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -294,6 +296,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 71f040097..669b2adb8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -115,6 +115,8 @@ const ( IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -366,6 +368,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPNS = 0x23 + SCM_TS_OPT_ID = 0x51 SCM_TXTIME = 0x3d SCM_WIFI_STATUS = 0x29 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index c44a31332..4834e5751 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -119,6 +119,8 @@ const ( IN_CLOEXEC = 0x400000 IN_NONBLOCK = 0x4000 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff ISIG = 0x1 IUCLC = 0x200 IXOFF = 0x1000 @@ -357,6 +359,7 @@ const ( SCM_TIMESTAMPING_OPT_STATS = 0x38 SCM_TIMESTAMPING_PKTINFO = 0x3c SCM_TIMESTAMPNS = 0x21 + SCM_TS_OPT_ID = 0x5a SCM_TXTIME = 0x3f SCM_WIFI_STATUS = 0x25 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index 829b87feb..c6545413c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -141,6 +141,16 @@ import ( //go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so" //go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" //go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" +//go:cgo_import_dynamic libc_getpeerucred getpeerucred "libc.so" +//go:cgo_import_dynamic libc_ucred_get ucred_get "libc.so" +//go:cgo_import_dynamic libc_ucred_geteuid ucred_geteuid "libc.so" +//go:cgo_import_dynamic libc_ucred_getegid ucred_getegid "libc.so" +//go:cgo_import_dynamic libc_ucred_getruid ucred_getruid "libc.so" +//go:cgo_import_dynamic libc_ucred_getrgid ucred_getrgid "libc.so" +//go:cgo_import_dynamic libc_ucred_getsuid ucred_getsuid "libc.so" +//go:cgo_import_dynamic libc_ucred_getsgid ucred_getsgid "libc.so" +//go:cgo_import_dynamic libc_ucred_getpid ucred_getpid "libc.so" +//go:cgo_import_dynamic libc_ucred_free ucred_free "libc.so" //go:cgo_import_dynamic libc_port_create port_create "libc.so" //go:cgo_import_dynamic libc_port_associate port_associate "libc.so" //go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so" @@ -280,6 +290,16 @@ import ( //go:linkname procgetpeername libc_getpeername //go:linkname procsetsockopt libc_setsockopt //go:linkname procrecvfrom libc_recvfrom +//go:linkname procgetpeerucred libc_getpeerucred +//go:linkname procucred_get libc_ucred_get +//go:linkname procucred_geteuid libc_ucred_geteuid +//go:linkname procucred_getegid libc_ucred_getegid +//go:linkname procucred_getruid libc_ucred_getruid +//go:linkname procucred_getrgid libc_ucred_getrgid +//go:linkname procucred_getsuid libc_ucred_getsuid +//go:linkname procucred_getsgid libc_ucred_getsgid +//go:linkname procucred_getpid libc_ucred_getpid +//go:linkname procucred_free libc_ucred_free //go:linkname procport_create libc_port_create //go:linkname procport_associate libc_port_associate //go:linkname procport_dissociate libc_port_dissociate @@ -420,6 +440,16 @@ var ( procgetpeername, procsetsockopt, procrecvfrom, + procgetpeerucred, + procucred_get, + procucred_geteuid, + procucred_getegid, + procucred_getruid, + procucred_getrgid, + procucred_getsuid, + procucred_getsgid, + procucred_getpid, + procucred_free, procport_create, procport_associate, procport_dissociate, @@ -2029,6 +2059,90 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getpeerucred(fd uintptr, ucred *uintptr) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetpeerucred)), 2, uintptr(fd), uintptr(unsafe.Pointer(ucred)), 0, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGet(pid int) (ucred uintptr, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procucred_get)), 1, uintptr(pid), 0, 0, 0, 0, 0) + ucred = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGeteuid(ucred uintptr) (uid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_geteuid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGetegid(ucred uintptr) (gid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getegid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGetruid(ucred uintptr) (uid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getruid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGetrgid(ucred uintptr) (gid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getrgid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGetsuid(ucred uintptr) (uid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getsuid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGetsgid(ucred uintptr) (gid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getsgid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredGetpid(ucred uintptr) (pid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getpid)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ucredFree(ucred uintptr) { + sysvicall6(uintptr(unsafe.Pointer(&procucred_free)), 1, uintptr(ucred), 0, 0, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func port_create() (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procport_create)), 0, 0, 0, 0, 0, 0, 0) n = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 524b0820c..c79aaff30 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -458,4 +458,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index f485dbf45..5eb450695 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -381,4 +381,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index 70b35bf3b..05e502974 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -422,4 +422,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index 1893e2fe8..38c53ec51 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -325,4 +325,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 16a4017da..31d2e71a1 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -321,4 +321,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index 7e567f1ef..f4184a336 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -442,4 +442,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 SYS_MSEAL = 4462 + SYS_SETXATTRAT = 4463 + SYS_GETXATTRAT = 4464 + SYS_LISTXATTRAT = 4465 + SYS_REMOVEXATTRAT = 4466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 38ae55e5e..05b996227 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -372,4 +372,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 SYS_MSEAL = 5462 + SYS_SETXATTRAT = 5463 + SYS_GETXATTRAT = 5464 + SYS_LISTXATTRAT = 5465 + SYS_REMOVEXATTRAT = 5466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index 55e92e60a..43a256e9e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -372,4 +372,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 SYS_MSEAL = 5462 + SYS_SETXATTRAT = 5463 + SYS_GETXATTRAT = 5464 + SYS_LISTXATTRAT = 5465 + SYS_REMOVEXATTRAT = 5466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index 60658d6a0..eea5ddfc2 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -442,4 +442,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 SYS_MSEAL = 4462 + SYS_SETXATTRAT = 4463 + SYS_GETXATTRAT = 4464 + SYS_LISTXATTRAT = 4465 + SYS_REMOVEXATTRAT = 4466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index e203e8a7e..0d777bfbb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -449,4 +449,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index 5944b97d5..b44636502 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -421,4 +421,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index c66d416da..0c7d21c18 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -421,4 +421,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index a5459e766..840539169 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -326,4 +326,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 01d86825b..fcf1b790d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -387,4 +387,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 7b703e77c..52d15b5f9 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -400,4 +400,8 @@ const ( SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 SYS_MSEAL = 462 + SYS_SETXATTRAT = 463 + SYS_GETXATTRAT = 464 + SYS_LISTXATTRAT = 465 + SYS_REMOVEXATTRAT = 466 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 5537148dc..a46abe647 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -4747,7 +4747,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x14c + NL80211_ATTR_MAX = 0x14d NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 @@ -5519,7 +5519,7 @@ const ( NL80211_MNTR_FLAG_CONTROL = 0x3 NL80211_MNTR_FLAG_COOK_FRAMES = 0x5 NL80211_MNTR_FLAG_FCSFAIL = 0x1 - NL80211_MNTR_FLAG_MAX = 0x6 + NL80211_MNTR_FLAG_MAX = 0x7 NL80211_MNTR_FLAG_OTHER_BSS = 0x4 NL80211_MNTR_FLAG_PLCPFAIL = 0x2 NL80211_MPATH_FLAG_ACTIVE = 0x1 @@ -6174,3 +6174,5 @@ type SockDiagReq struct { Family uint8 Protocol uint8 } + +const RTM_NEWNVLAN = 0x70 diff --git a/vendor/modules.txt b/vendor/modules.txt index 73d9ee847..49ca611b2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1050,7 +1050,7 @@ go.uber.org/multierr # golang.org/x/arch v0.13.0 ## explicit; go 1.18 golang.org/x/arch/x86/x86asm -# golang.org/x/crypto v0.32.0 +# golang.org/x/crypto v0.33.0 ## explicit; go 1.20 golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert @@ -1115,7 +1115,7 @@ golang.org/x/oauth2/internal ## explicit; go 1.18 golang.org/x/sync/errgroup golang.org/x/sync/semaphore -# golang.org/x/sys v0.29.0 +# golang.org/x/sys v0.30.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix From 2c95fd41155e6c419145ed57acfeb32b8b59f3d6 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 11 Feb 2025 09:42:35 +0100 Subject: [PATCH 14/14] [bugfix] Suggest lowercase username when creating via OIDC (#3780) --- internal/api/auth/callback.go | 8 +++++++- web/template/finalize.tmpl | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/api/auth/callback.go b/internal/api/auth/callback.go index 37c257229..2dc36fac8 100644 --- a/internal/api/auth/callback.go +++ b/internal/api/auth/callback.go @@ -145,12 +145,18 @@ func (m *Module) CallbackGETHandler(c *gin.Context) { return } + // Since we require lowercase usernames at this point, lowercase the one + // from the claims and use this to autofill the form with a suggestion. + // + // Pending https://github.com/superseriousbusiness/gotosocial/issues/1813 + suggestedUsername := strings.ToLower(claims.PreferredUsername) + page := apiutil.WebPage{ Template: "finalize.tmpl", Instance: instance, Extra: map[string]any{ "name": claims.Name, - "preferredUsername": claims.PreferredUsername, + "suggestedUsername": suggestedUsername, }, } diff --git a/web/template/finalize.tmpl b/web/template/finalize.tmpl index 861dc635f..8b63e0929 100644 --- a/web/template/finalize.tmpl +++ b/web/template/finalize.tmpl @@ -42,7 +42,7 @@ placeholder="Please enter your desired username" pattern="^[a-z0-9_]{1,64}$" title="lowercase a-z, numbers, and underscores; max 64 characters" - value="{{- .preferredUsername -}}" + value="{{- .suggestedUsername -}}" >