@ -48,7 +48,7 @@ import (
)
)
const (
const (
tail FSPrefix = "/v0/tailfs "
tail drivePrefix = "/v0/drive "
)
)
var initListenConfig func ( * net . ListenConfig , netip . Addr , * interfaces . State , string ) error
var initListenConfig func ( * net . ListenConfig , netip . Addr , * interfaces . State , string ) error
@ -324,7 +324,7 @@ func (h *peerAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h . handleDNSQuery ( w , r )
h . handleDNSQuery ( w , r )
return
return
}
}
if strings . HasPrefix ( r . URL . Path , tail FS Prefix) {
if strings . HasPrefix ( r . URL . Path , tail drive Prefix) {
h . handleServeDrive ( w , r )
h . handleServeDrive ( w , r )
return
return
}
}
@ -1143,16 +1143,16 @@ func (rbw *requestBodyWrapper) Read(b []byte) (int, error) {
func ( h * peerAPIHandler ) handleServeDrive ( w http . ResponseWriter , r * http . Request ) {
func ( h * peerAPIHandler ) handleServeDrive ( w http . ResponseWriter , r * http . Request ) {
if ! h . ps . b . DriveSharingEnabled ( ) {
if ! h . ps . b . DriveSharingEnabled ( ) {
h . logf ( "tail fs : not enabled")
h . logf ( "tail drive : not enabled")
http . Error ( w , "tail fs not enabled", http . StatusNotFound )
http . Error ( w , "tail drive not enabled", http . StatusNotFound )
return
return
}
}
capsMap := h . peerCaps ( )
capsMap := h . peerCaps ( )
driveCaps , ok := capsMap [ tailcfg . PeerCapabilityTail FS ]
driveCaps , ok := capsMap [ tailcfg . PeerCapabilityTail drive ]
if ! ok {
if ! ok {
h . logf ( "tail fs : not permitted")
h . logf ( "tail drive : not permitted")
http . Error ( w , "tail fs not permitted", http . StatusForbidden )
http . Error ( w , "tail drive not permitted", http . StatusForbidden )
return
return
}
}
@ -1163,15 +1163,15 @@ func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request
p , err := drive . ParsePermissions ( rawPerms )
p , err := drive . ParsePermissions ( rawPerms )
if err != nil {
if err != nil {
h . logf ( "tail fs : error parsing permissions: %w", err . Error ( ) )
h . logf ( "tail drive : error parsing permissions: %w", err . Error ( ) )
http . Error ( w , err . Error ( ) , http . StatusInternalServerError )
http . Error ( w , err . Error ( ) , http . StatusInternalServerError )
return
return
}
}
fs , ok := h . ps . b . sys . DriveForRemote . GetOK ( )
fs , ok := h . ps . b . sys . DriveForRemote . GetOK ( )
if ! ok {
if ! ok {
h . logf ( "tail fs : not supported on platform")
h . logf ( "tail drive : not supported on platform")
http . Error ( w , "tail fs not supported on platform", http . StatusNotFound )
http . Error ( w , "tail drive not supported on platform", http . StatusNotFound )
return
return
}
}
wr := & httpResponseWrapper {
wr := & httpResponseWrapper {
@ -1193,12 +1193,12 @@ func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request
contentType = ct
contentType = ct
}
}
h . logf ( "tail fs : share: %s from %s to %s: status-code=%d ext=%q content-type=%q tx=%.f rx=%.f", r . Method , h . peerNode . Key ( ) . ShortString ( ) , h . selfNode . Key ( ) . ShortString ( ) , wr . statusCode , parseDriveFileExtensionForLog ( r . URL . Path ) , contentType , roundTraffic ( wr . contentLength ) , roundTraffic ( bw . bytesRead ) )
h . logf ( "tail drive : share: %s from %s to %s: status-code=%d ext=%q content-type=%q tx=%.f rx=%.f", r . Method , h . peerNode . Key ( ) . ShortString ( ) , h . selfNode . Key ( ) . ShortString ( ) , wr . statusCode , parseDriveFileExtensionForLog ( r . URL . Path ) , contentType , roundTraffic ( wr . contentLength ) , roundTraffic ( bw . bytesRead ) )
}
}
} ( )
} ( )
}
}
r . URL . Path = strings . TrimPrefix ( r . URL . Path , tail FS Prefix)
r . URL . Path = strings . TrimPrefix ( r . URL . Path , tail drive Prefix)
fs . ServeHTTPWithPerms ( p , wr , r )
fs . ServeHTTPWithPerms ( p , wr , r )
}
}