Skip to content

Commit e1fd85c

Browse files
Merge branch 'main' into fix-mirror-sanitize
2 parents 8218106 + a005265 commit e1fd85c

File tree

1,125 files changed

+42451
-38036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,125 files changed

+42451
-38036
lines changed

.golangci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ issues:
7070
- path: modules/log/
7171
linters:
7272
- errcheck
73-
- path: routers/routes/web.go
74-
linters:
75-
- dupl
7673
- path: routers/api/v1/repo/issue_subscription.go
7774
linters:
7875
- dupl
@@ -114,3 +111,4 @@ issues:
114111
linters:
115112
- staticcheck
116113
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
114+

Dockerfile.rootless

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ USER git:git
6060
ENV GITEA_WORK_DIR /var/lib/gitea
6161
ENV GITEA_CUSTOM /var/lib/gitea/custom
6262
ENV GITEA_TEMP /tmp/gitea
63+
ENV TMPDIR /tmp/gitea
64+
6365
#TODO add to docs the ability to define the ini to load (usefull to test and revert a config)
6466
ENV GITEA_APP_INI /etc/gitea/app.ini
6567
ENV HOME "/var/lib/gitea/git"

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ endif
4343
ifeq ($(OS), Windows_NT)
4444
GOFLAGS := -v -buildmode=exe
4545
EXECUTABLE ?= gitea.exe
46+
else ifeq ($(OS), Windows)
47+
GOFLAGS := -v -buildmode=exe
48+
EXECUTABLE ?= gitea.exe
4649
else
4750
GOFLAGS := -v
4851
EXECUTABLE ?= gitea
@@ -61,8 +64,9 @@ EXTRA_GOFLAGS ?=
6164
MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
6265
MAKE_EVIDENCE_DIR := .make_evidence
6366

64-
ifneq ($(RACE_ENABLED),)
65-
GOTESTFLAGS ?= -race
67+
ifeq ($(RACE_ENABLED),true)
68+
GOFLAGS += -race
69+
GOTESTFLAGS += -race
6670
endif
6771

6872
STORED_VERSION_FILE := VERSION
@@ -377,7 +381,7 @@ test-check:
377381
.PHONY: test\#%
378382
test\#%:
379383
@echo "Running go test with -tags '$(TEST_TAGS)'..."
380-
@$(GO) test -mod=vendor -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
384+
@$(GO) test -mod=vendor $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
381385

382386
.PHONY: coverage
383387
coverage:

cmd/web.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import (
1616
"code.gitea.io/gitea/modules/graceful"
1717
"code.gitea.io/gitea/modules/log"
1818
"code.gitea.io/gitea/modules/setting"
19-
"code.gitea.io/gitea/modules/util"
2019
"code.gitea.io/gitea/routers"
21-
"code.gitea.io/gitea/routers/routes"
20+
"code.gitea.io/gitea/routers/install"
2221

2322
context2 "github.com/gorilla/context"
2423
"github.com/urfave/cli"
@@ -89,7 +88,7 @@ func runWeb(ctx *cli.Context) error {
8988
}
9089

9190
// Perform pre-initialization
92-
needsInstall := routers.PreInstallInit(graceful.GetManager().HammerContext())
91+
needsInstall := install.PreloadSettings(graceful.GetManager().HammerContext())
9392
if needsInstall {
9493
// Flag for port number in case first time run conflict
9594
if ctx.IsSet("port") {
@@ -102,7 +101,7 @@ func runWeb(ctx *cli.Context) error {
102101
return err
103102
}
104103
}
105-
c := routes.InstallRoutes()
104+
c := install.Routes()
106105
err := listen(c, false)
107106
select {
108107
case <-graceful.GetManager().IsShutdown():
@@ -135,7 +134,7 @@ func runWeb(ctx *cli.Context) error {
135134
}
136135

137136
// Set up Chi routes
138-
c := routes.NormalRoutes()
137+
c := routers.NormalRoutes()
139138
err := listen(c, true)
140139
<-graceful.GetManager().Done()
141140
log.Info("PID: %d Gitea Web Finished", os.Getpid())
@@ -152,19 +151,6 @@ func setPort(port string) error {
152151
case setting.FCGI:
153152
case setting.FCGIUnix:
154153
default:
155-
// Save LOCAL_ROOT_URL if port changed
156-
cfg := ini.Empty()
157-
isFile, err := util.IsFile(setting.CustomConf)
158-
if err != nil {
159-
log.Fatal("Unable to check if %s is a file", err)
160-
}
161-
if isFile {
162-
// Keeps custom settings if there is already something.
163-
if err := cfg.Append(setting.CustomConf); err != nil {
164-
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)
165-
}
166-
}
167-
168154
defaultLocalURL := string(setting.Protocol) + "://"
169155
if setting.HTTPAddr == "0.0.0.0" {
170156
defaultLocalURL += "localhost"
@@ -173,10 +159,10 @@ func setPort(port string) error {
173159
}
174160
defaultLocalURL += ":" + setting.HTTPPort + "/"
175161

176-
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
177-
if err := cfg.SaveTo(setting.CustomConf); err != nil {
178-
return fmt.Errorf("Error saving generated LOCAL_ROOT_URL to custom config: %v", err)
179-
}
162+
// Save LOCAL_ROOT_URL if port changed
163+
setting.CreateOrAppendToCustomConf(func(cfg *ini.File) {
164+
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
165+
})
180166
}
181167
return nil
182168
}

contrib/pr/checkout.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"code.gitea.io/gitea/modules/setting"
3232
"code.gitea.io/gitea/modules/util"
3333
"code.gitea.io/gitea/routers"
34-
"code.gitea.io/gitea/routers/routes"
3534

3635
"github.com/go-git/go-git/v5"
3736
"github.com/go-git/go-git/v5/config"
@@ -116,7 +115,7 @@ func runPR() {
116115
//routers.GlobalInit()
117116
external.RegisterRenderers()
118117
markup.Init()
119-
c := routes.NormalRoutes()
118+
c := routers.NormalRoutes()
120119

121120
log.Printf("[PR] Ready for testing !\n")
122121
log.Printf("[PR] Login with user1, user2, user3, ... with pass: password\n")

custom/conf/app.example.ini

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ RUN_MODE = ; prod
5151
;REDIRECT_OTHER_PORT = false
5252
;PORT_TO_REDIRECT = 80
5353
;;
54+
;; Timeout for any write to the connection. (Set to 0 to disable all timeouts.)
55+
;PER_WRITE_TIMEOUT = 30s
56+
;;
57+
;; Timeout per Kb written to connections.
58+
;PER_WRITE_PER_KB_TIMEOUT = 30s
59+
;;
5460
;; Permission for unix socket
5561
;UNIX_SOCKET_PERMISSION = 666
5662
;;
@@ -144,6 +150,14 @@ RUN_MODE = ; prod
144150
;; Enable exposure of SSH clone URL to anonymous visitors, default is false
145151
;SSH_EXPOSE_ANONYMOUS = false
146152
;;
153+
;; Timeout for any write to ssh connections. (Set to 0 to disable all timeouts.)
154+
;; Will default to the PER_WRITE_TIMEOUT.
155+
;SSH_PER_WRITE_TIMEOUT = 30s
156+
;;
157+
;; Timeout per Kb written to ssh connections.
158+
;; Will default to the PER_WRITE_PER_KB_TIMEOUT.
159+
;SSH_PER_WRITE_PER_KB_TIMEOUT = 30s
160+
;;
147161
;; Indicate whether to check minimum key size with corresponding type
148162
;MINIMUM_KEY_SIZE_CHECK = false
149163
;;
@@ -1145,8 +1159,8 @@ PATH =
11451159
;;
11461160
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
11471161
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
1148-
;; default is indexers/issues.queue
1149-
;ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
1162+
;; default is queues/common
1163+
;ISSUE_INDEXER_QUEUE_DIR = queues/common
11501164
;;
11511165
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
11521166
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
@@ -1201,7 +1215,7 @@ PATH =
12011215
;; default to persistable-channel
12021216
;TYPE = persistable-channel
12031217
;;
1204-
;; data-dir for storing persistable queues and level queues, individual queues will be named by their type
1218+
;; data-dir for storing persistable queues and level queues, individual queues will default to `queues/common` meaning the queue is shared.
12051219
;DATADIR = queues/
12061220
;;
12071221
;; Default queue length before a channel queue will block
@@ -1231,7 +1245,7 @@ PATH =
12311245
;TIMEOUT = 15m30s
12321246
;;
12331247
;; Create a pool with this many workers
1234-
;WORKERS = 1
1248+
;WORKERS = 0
12351249
;;
12361250
;; Dynamically scale the worker pool to at this many workers
12371251
;MAX_WORKERS = 10
@@ -1243,7 +1257,7 @@ PATH =
12431257
;BOOST_TIMEOUT = 5m
12441258
;;
12451259
;; During a boost add BOOST_WORKERS
1246-
;BOOST_WORKERS = 5
1260+
;BOOST_WORKERS = 1
12471261

12481262
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12491263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docker/root/etc/s6/openssh/setup

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ if [ -d /etc/ssh ]; then
4747
SSH_RSA_CERT="${SSH_RSA_CERT:+"HostCertificate "}${SSH_RSA_CERT}" \
4848
SSH_ECDSA_CERT="${SSH_ECDSA_CERT:+"HostCertificate "}${SSH_ECDSA_CERT}" \
4949
SSH_DSA_CERT="${SSH_DSA_CERT:+"HostCertificate "}${SSH_DSA_CERT}" \
50+
SSH_MAX_STARTUPS="${SSH_MAX_STARTUPS:+"MaxStartups "}${SSH_MAX_STARTUPS}" \
51+
SSH_MAX_SESSIONS="${SSH_MAX_SESSIONS:+"MaxSessions "}${SSH_MAX_SESSIONS}" \
5052
envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config
5153

5254
chmod 0644 /etc/ssh/sshd_config

docker/root/etc/templates/sshd_config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ AddressFamily any
55
ListenAddress 0.0.0.0
66
ListenAddress ::
77

8+
${SSH_MAX_STARTUPS}
9+
${SSH_MAX_SESSIONS}
10+
811
LogLevel INFO
912

1013
HostKey /data/ssh/ssh_host_ed25519_key

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ update: $(THEME)
3131
$(THEME): $(THEME)/theme.toml
3232
$(THEME)/theme.toml:
3333
mkdir -p $$(dirname $@)
34-
curl -s $(ARCHIVE) | tar xz -C $$(dirname $@)
34+
curl -L -s $(ARCHIVE) | tar xz -C $$(dirname $@)

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
251251
most cases you do not need to change the default value. Alter it only if
252252
your SSH server node is not the same as HTTP node. Do not set this variable
253253
if `PROTOCOL` is set to `unix`.
254+
- `PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the connection. (Set to 0 to
255+
disable all timeouts.)
256+
- `PER_WRITE_PER_KB_TIMEOUT`: **10s**: Timeout per Kb written to connections.
254257

255258
- `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
256259
- `START_SSH_SERVER`: **false**: When enabled, use the built-in SSH server.
@@ -274,6 +277,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
274277
- `SSH_KEY_TEST_PATH`: **/tmp**: Directory to create temporary files in when testing public keys using ssh-keygen, default is the system temporary directory.
275278
- `SSH_KEYGEN_PATH`: **ssh-keygen**: Path to ssh-keygen, default is 'ssh-keygen' which means the shell is responsible for finding out which one to call.
276279
- `SSH_EXPOSE_ANONYMOUS`: **false**: Enable exposure of SSH clone URL to anonymous visitors, default is false.
280+
- `SSH_PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the SSH connections. (Set to
281+
0 to disable all timeouts.)
282+
- `SSH_PER_WRITE_PER_KB_TIMEOUT`: **10s**: Timeout per Kb written to SSH connections.
277283
- `MINIMUM_KEY_SIZE_CHECK`: **true**: Indicate whether to check minimum key size with corresponding type.
278284

279285
- `OFFLINE_MODE`: **false**: Disables use of CDN for static files and Gravatar for profile pictures.
@@ -350,7 +356,7 @@ relation to port exhaustion.
350356
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
351357
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
352358
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
353-
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved.
359+
- `ISSUE_INDEXER_QUEUE_DIR`: **queues/common**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved. (Previously this was `indexers/issues.queue`.)
354360
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
355361
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
356362

@@ -370,7 +376,7 @@ relation to port exhaustion.
370376
## Queue (`queue` and `queue.*`)
371377

372378
- `TYPE`: **persistable-channel**: General queue type, currently support: `persistable-channel` (uses a LevelDB internally), `channel`, `level`, `redis`, `dummy`
373-
- `DATADIR`: **queues/**: Base DataDir for storing persistent and level queues. `DATADIR` for individual queues can be set in `queue.name` sections but will default to `DATADIR/`**`name`**.
379+
- `DATADIR`: **queues/**: Base DataDir for storing persistent and level queues. `DATADIR` for individual queues can be set in `queue.name` sections but will default to `DATADIR/`**`common`**. (Previously each queue would default to `DATADIR/`**`name`**.)
374380
- `LENGTH`: **20**: Maximal queue size before channel queues block
375381
- `BATCH_LENGTH`: **20**: Batch data before passing to the handler
376382
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. Options can be set using query params. Similarly LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**, and will override `DATADIR`
@@ -381,11 +387,11 @@ relation to port exhaustion.
381387
- `MAX_ATTEMPTS`: **10**: Maximum number of attempts to create the wrapped queue
382388
- `TIMEOUT`: **GRACEFUL_HAMMER_TIME + 30s**: Timeout the creation of the wrapped queue if it takes longer than this to create.
383389
- Queues by default come with a dynamically scaling worker pool. The following settings configure this:
384-
- `WORKERS`: **1**: Number of initial workers for the queue.
390+
- `WORKERS`: **0** (v1.14 and before: **1**): Number of initial workers for the queue.
385391
- `MAX_WORKERS`: **10**: Maximum number of worker go-routines for the queue.
386392
- `BLOCK_TIMEOUT`: **1s**: If the queue blocks for this time, boost the number of workers - the `BLOCK_TIMEOUT` will then be doubled before boosting again whilst the boost is ongoing.
387393
- `BOOST_TIMEOUT`: **5m**: Boost workers will timeout after this long.
388-
- `BOOST_WORKERS`: **5**: This many workers will be added to the worker pool if there is a boost.
394+
- `BOOST_WORKERS`: **1** (v1.14 and before: **5**): This many workers will be added to the worker pool if there is a boost.
389395

390396
## Admin (`admin`)
391397

0 commit comments

Comments
 (0)