2017-09-23 13:56:58 +08:00
|
|
|
// Copyright 2015 Light Code Labs, LLC
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
package log
|
2015-06-19 21:45:57 +08:00
|
|
|
|
|
|
|
import (
|
2017-12-23 18:52:11 +08:00
|
|
|
"net"
|
2017-02-08 23:02:09 +08:00
|
|
|
"reflect"
|
2017-12-23 18:52:11 +08:00
|
|
|
"testing"
|
2017-02-08 23:02:09 +08:00
|
|
|
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
"github.com/mholt/caddy"
|
|
|
|
"github.com/mholt/caddy/caddyhttp/httpserver"
|
2015-06-19 21:45:57 +08:00
|
|
|
)
|
|
|
|
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
func TestSetup(t *testing.T) {
|
2016-06-21 01:44:20 +08:00
|
|
|
c := caddy.NewTestController("http", `log`)
|
|
|
|
err := setup(c)
|
2015-06-19 21:45:57 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Expected no errors, got: %v", err)
|
|
|
|
}
|
2016-06-21 01:44:20 +08:00
|
|
|
cfg := httpserver.GetConfig(c)
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
mids := cfg.Middleware()
|
|
|
|
if mids == nil {
|
2015-06-19 21:45:57 +08:00
|
|
|
t.Fatal("Expected middleware, was nil instead")
|
|
|
|
}
|
|
|
|
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
handler := mids[0](httpserver.EmptyNext)
|
|
|
|
myHandler, ok := handler.(Logger)
|
2015-06-19 21:45:57 +08:00
|
|
|
|
|
|
|
if !ok {
|
2015-06-20 01:00:48 +08:00
|
|
|
t.Fatalf("Expected handler to be type Logger, got: %#v", handler)
|
2015-06-19 21:45:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if myHandler.Rules[0].PathScope != "/" {
|
|
|
|
t.Errorf("Expected / as the default PathScope")
|
|
|
|
}
|
2017-02-08 23:02:09 +08:00
|
|
|
|
2017-02-09 00:23:33 +08:00
|
|
|
expectedLogger := &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: DefaultLogFilename,
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
}
|
2017-02-08 23:02:09 +08:00
|
|
|
|
|
|
|
if !reflect.DeepEqual(myHandler.Rules[0].Entries[0].Log, expectedLogger) {
|
|
|
|
t.Errorf("Expected %v as the default Log, got: %v", expectedLogger, myHandler.Rules[0].Entries[0].Log)
|
2015-06-19 21:45:57 +08:00
|
|
|
}
|
2016-08-22 15:40:14 +08:00
|
|
|
if myHandler.Rules[0].Entries[0].Format != DefaultLogFormat {
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
t.Errorf("Expected %s as the default Log Format", DefaultLogFormat)
|
2015-06-19 21:45:57 +08:00
|
|
|
}
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) {
|
2015-06-19 21:45:57 +08:00
|
|
|
t.Error("'Next' field of handler was not set properly")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLogParse(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
inputLogRules string
|
|
|
|
shouldErr bool
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
expectedLogRules []Rule
|
2015-06-19 21:45:57 +08:00
|
|
|
}{
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
{`log`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: DefaultLogFilename,
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 21:45:57 +08:00
|
|
|
}}},
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
{`log log.txt`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
|
|
|
}},
|
|
|
|
}}},
|
|
|
|
{`log syslog://127.0.0.1:5000`, false, []Rule{{
|
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "syslog://127.0.0.1:5000",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
|
|
|
}},
|
|
|
|
}}},
|
|
|
|
{`log syslog+tcp://127.0.0.1:5000`, false, []Rule{{
|
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "syslog+tcp://127.0.0.1:5000",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 21:45:57 +08:00
|
|
|
}}},
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
{`log /api log.txt`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/api",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 21:45:57 +08:00
|
|
|
}}},
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
{`log /serve stdout`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/serve",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "stdout",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}}},
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
{`log /myapi log.txt {common}`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/myapi",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: CommonLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}}},
|
2017-05-11 16:15:41 +08:00
|
|
|
{`log /myapi log.txt "prefix {common} suffix"`, false, []Rule{{
|
|
|
|
PathScope: "/myapi",
|
|
|
|
Entries: []*Entry{{
|
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-05-11 16:15:41 +08:00
|
|
|
},
|
|
|
|
Format: "prefix " + CommonLogFormat + " suffix",
|
|
|
|
}},
|
|
|
|
}}},
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
{`log /test accesslog.txt {combined}`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/test",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "accesslog.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: CombinedLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}}},
|
2017-05-11 16:15:41 +08:00
|
|
|
{`log /test accesslog.txt "prefix {combined} suffix"`, false, []Rule{{
|
|
|
|
PathScope: "/test",
|
|
|
|
Entries: []*Entry{{
|
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "accesslog.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-05-11 16:15:41 +08:00
|
|
|
},
|
|
|
|
Format: "prefix " + CombinedLogFormat + " suffix",
|
|
|
|
}},
|
|
|
|
}}},
|
2015-09-02 21:13:31 +08:00
|
|
|
{`log /api1 log.txt
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
log /api2 accesslog.txt {combined}`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/api1",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}, {
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/api2",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "accesslog.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: CombinedLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}}},
|
|
|
|
{`log /api3 stdout {host}
|
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.
The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.
The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.
The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.
Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.
A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).
Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.
Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.
Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.
I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-05 07:00:29 +08:00
|
|
|
log /api4 log.txt {when}`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/api3",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "stdout",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: "{host}",
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}, {
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/api4",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: "{when}",
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-06-19 22:07:48 +08:00
|
|
|
}}},
|
2017-07-20 15:16:43 +08:00
|
|
|
{`log access.log {
|
|
|
|
rotate_size 2
|
|
|
|
rotate_age 10
|
|
|
|
rotate_keep 3
|
|
|
|
rotate_compress
|
|
|
|
}`, false, []Rule{{
|
2016-08-22 15:40:14 +08:00
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
|
|
|
Output: "access.log",
|
|
|
|
Roller: &httpserver.LogRoller{
|
|
|
|
MaxSize: 2,
|
|
|
|
MaxAge: 10,
|
|
|
|
MaxBackups: 3,
|
2017-07-20 15:16:43 +08:00
|
|
|
Compress: true,
|
2017-02-09 00:23:33 +08:00
|
|
|
LocalTime: true,
|
2017-12-23 18:52:11 +08:00
|
|
|
},
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
|
|
|
},
|
|
|
|
|
|
|
|
Format: DefaultLogFormat,
|
|
|
|
}},
|
|
|
|
}}},
|
|
|
|
{`log access0.log {
|
|
|
|
ipmask 255.255.255.0
|
|
|
|
}`, false, []Rule{{
|
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
|
|
|
Log: &httpserver.Logger{
|
|
|
|
Output: "access0.log",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP("255.255.255.0").To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
|
|
|
IPMaskExists: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
Format: DefaultLogFormat,
|
|
|
|
}},
|
|
|
|
}}},
|
|
|
|
{`log access1.log {
|
|
|
|
ipmask "" ffff:ffff:ffff:ff00::
|
|
|
|
}`, false, []Rule{{
|
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
|
|
|
Log: &httpserver.Logger{
|
|
|
|
Output: "access1.log",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP("ffff:ffff:ffff:ff00::")),
|
|
|
|
IPMaskExists: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
Format: DefaultLogFormat,
|
|
|
|
}},
|
|
|
|
}}},
|
|
|
|
{`log access2.log {
|
|
|
|
ipmask 255.255.255.0 ffff:ffff:ffff:ff00::
|
|
|
|
}`, false, []Rule{{
|
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
|
|
|
Log: &httpserver.Logger{
|
|
|
|
Output: "access2.log",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP("255.255.255.0").To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP("ffff:ffff:ffff:ff00::")),
|
|
|
|
IPMaskExists: true,
|
|
|
|
},
|
|
|
|
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: DefaultLogFormat,
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
|
|
|
}}},
|
|
|
|
{`log / stdout {host}
|
|
|
|
log / log.txt {when}`, false, []Rule{{
|
|
|
|
PathScope: "/",
|
|
|
|
Entries: []*Entry{{
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "stdout",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: "{host}",
|
2016-08-22 15:40:14 +08:00
|
|
|
}, {
|
2017-02-09 00:23:33 +08:00
|
|
|
Log: &httpserver.Logger{
|
2017-12-23 18:52:11 +08:00
|
|
|
Output: "log.txt",
|
|
|
|
Roller: httpserver.DefaultLogRoller(),
|
|
|
|
V4ipMask: net.IPMask(net.ParseIP(DefaultIP4Mask).To4()),
|
|
|
|
V6ipMask: net.IPMask(net.ParseIP(DefaultIP6Mask)),
|
2017-02-09 00:23:33 +08:00
|
|
|
},
|
2017-02-08 23:02:09 +08:00
|
|
|
Format: "{when}",
|
2016-08-22 15:40:14 +08:00
|
|
|
}},
|
2015-09-02 21:13:31 +08:00
|
|
|
}}},
|
2017-07-20 15:16:43 +08:00
|
|
|
{`log access.log { rotate_size 2 rotate_age 10 rotate_keep 3 }`, true, nil},
|
|
|
|
{`log access.log { rotate_compress invalid }`, true, nil},
|
2017-04-17 16:51:37 +08:00
|
|
|
{`log access.log { rotate_size }`, true, nil},
|
2017-12-23 18:52:11 +08:00
|
|
|
{`log access.log { ipmask }`, true, nil},
|
2017-04-17 16:51:37 +08:00
|
|
|
{`log access.log { invalid_option 1 }`, true, nil},
|
2017-05-17 23:51:58 +08:00
|
|
|
{`log / acccess.log "{remote} - [{when}] "{method} {port}" {scheme} {mitm} "`, true, nil},
|
2015-06-19 21:45:57 +08:00
|
|
|
}
|
|
|
|
for i, test := range tests {
|
2016-06-21 01:44:20 +08:00
|
|
|
c := caddy.NewTestController("http", test.inputLogRules)
|
2015-06-19 21:45:57 +08:00
|
|
|
actualLogRules, err := logParse(c)
|
|
|
|
|
|
|
|
if err == nil && test.shouldErr {
|
|
|
|
t.Errorf("Test %d didn't error, but it should have", i)
|
|
|
|
} else if err != nil && !test.shouldErr {
|
|
|
|
t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err)
|
|
|
|
}
|
|
|
|
if len(actualLogRules) != len(test.expectedLogRules) {
|
|
|
|
t.Fatalf("Test %d expected %d no of Log rules, but got %d ",
|
|
|
|
i, len(test.expectedLogRules), len(actualLogRules))
|
|
|
|
}
|
|
|
|
for j, actualLogRule := range actualLogRules {
|
|
|
|
|
|
|
|
if actualLogRule.PathScope != test.expectedLogRules[j].PathScope {
|
|
|
|
t.Errorf("Test %d expected %dth LogRule PathScope to be %s , but got %s",
|
|
|
|
i, j, test.expectedLogRules[j].PathScope, actualLogRule.PathScope)
|
|
|
|
}
|
|
|
|
|
2016-08-22 15:40:14 +08:00
|
|
|
if got, expect := len(actualLogRule.Entries), len(test.expectedLogRules[j].Entries); got != expect {
|
|
|
|
t.Fatalf("Test %d expected %dth LogRule with %d no of Log entries, but got %d ",
|
|
|
|
i, j, expect, got)
|
2015-06-19 21:45:57 +08:00
|
|
|
}
|
|
|
|
|
2016-08-22 15:40:14 +08:00
|
|
|
for k, actualEntry := range actualLogRule.Entries {
|
2017-02-08 23:02:09 +08:00
|
|
|
if !reflect.DeepEqual(actualEntry.Log, test.expectedLogRules[j].Entries[k].Log) {
|
|
|
|
t.Errorf("Test %d expected %dth LogRule Log to be %v , but got %v",
|
|
|
|
i, j, test.expectedLogRules[j].Entries[k].Log, actualEntry.Log)
|
2015-09-02 21:13:31 +08:00
|
|
|
}
|
2016-08-22 15:40:14 +08:00
|
|
|
|
|
|
|
if actualEntry.Format != test.expectedLogRules[j].Entries[k].Format {
|
|
|
|
t.Errorf("Test %d expected %dth LogRule Format to be %s , but got %s",
|
|
|
|
i, j, test.expectedLogRules[j].Entries[k].Format, actualEntry.Format)
|
2015-09-02 21:13:31 +08:00
|
|
|
}
|
|
|
|
}
|
2015-06-19 21:45:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|