@ -50,9 +50,8 @@ const MapPage = (props) => {
e . target . reset ( ) ;
e . target . reset ( ) ;
}
}
async function deleteFromMap ( e ) {
async function deleteFromMap ( csrf , key ) {
e . preventDefault ( ) ;
await API . deleteFromMap ( mapInfo . name , { _csrf : csrf , key } , dispatch , setError , router ) ;
await API . deleteFromMap ( mapInfo . name , { _csrf : csrf , key : e . target . key . value } , dispatch , setError , router ) ;
await API . getMap ( mapName , dispatch , setError , router ) ;
await API . getMap ( mapName , dispatch , setError , router ) ;
}
}
@ -80,13 +79,18 @@ const MapPage = (props) => {
. map ( ( entry , i ) => ( < option key = { 'option' + i } value = { entry [ 0 ] } > { entry [ 1 ] } < / o p t i o n > ) )
. map ( ( entry , i ) => ( < option key = { 'option' + i } value = { entry [ 0 ] } > { entry [ 1 ] } < / o p t i o n > ) )
formElements = (
formElements = (
< >
< >
< input type = "hidden" name = "_csrf" value = { csrf } / >
< td >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "form-control mx-3" type = "text" name = "key" placeholder = "domain/path" required / >
< / t d >
< select className = "form-select mx-3" name = "value" defaultValue = "" required >
< td >
< option value = "" / >
< input className = "form-control" type = "text" name = "key" placeholder = "domain/path" required / >
{ mapValueOptions }
< / t d >
< / s e l e c t >
< td >
< select className = "form-select" name = "value" defaultValue = "" required >
< option value = "" / >
{ mapValueOptions }
< / s e l e c t >
< / t d >
< / >
< / >
) ;
) ;
break ;
break ;
@ -95,23 +99,34 @@ const MapPage = (props) => {
const domainSelectOptions = user . domains . map ( ( d , i ) => ( < option key = { 'option' + i } value = { d } > { d } < / o p t i o n > ) ) ;
const domainSelectOptions = user . domains . map ( ( d , i ) => ( < option key = { 'option' + i } value = { d } > { d } < / o p t i o n > ) ) ;
formElements = (
formElements = (
< >
< >
< input type = "hidden" name = "_csrf" value = { csrf } / >
< td >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "btn btn-success" type = "submit" value = "+" / >
< select className = "form-select mx-3" name = "key" defaultValue = "" required >
< / t d >
< option value = "" / >
< td >
{ domainSelectOptions }
< select className = "form-select" name = "key" defaultValue = "" required >
< / s e l e c t >
< option value = "" / >
< input className = "form-control mx-3" type = "number" name = "pd" placeholder = "difficulty" required / >
{ domainSelectOptions }
< select className = "form-select mx-3" name = "pt" required >
< / s e l e c t >
< option disabled value = "" > pow type < / o p t i o n >
< / t d >
< option value = "sha256" > sha256 < / o p t i o n >
< td >
< option value = "argon2" > argon2 < / o p t i o n >
< input className = "form-control" type = "number" name = "pd" placeholder = "difficulty" required / >
< / s e l e c t >
< / t d >
< input className = "form-control mx-3" type = "number" name = "cex" placeholder = "cookie expiry (seconds)" required / >
< td >
< div className = "form-check" >
< select className = "form-select" name = "pt" required >
< input className = "form-check-input" type = "checkbox" name = "cip" value = "cip" id = "cip" / >
< option disabled value = "" > pow type < / o p t i o n >
< label className = "form-check-label" htmlFor = "cip" > Lock cookie to IP < / l a b e l >
< option value = "sha256" > sha256 < / o p t i o n >
< / d i v >
< option value = "argon2" > argon2 < / o p t i o n >
< / s e l e c t >
< / t d >
< td >
< input className = "form-control" type = "number" name = "cex" placeholder = "cookie expiry (seconds)" required / >
< / t d >
< td >
< div className = "form-check" >
< input className = "form-check-input" type = "checkbox" name = "cip" value = "cip" id = "cip" / >
< label className = "form-check-label" htmlFor = "cip" > Lock cookie to IP < / l a b e l >
< / d i v >
< / t d >
< / >
< / >
) ;
) ;
break ;
break ;
@ -120,21 +135,26 @@ const MapPage = (props) => {
const domainSelectOptions = user . domains . map ( ( d , i ) => ( < option key = { 'option' + i } value = { d } > { d } < / o p t i o n > ) ) ;
const domainSelectOptions = user . domains . map ( ( d , i ) => ( < option key = { 'option' + i } value = { d } > { d } < / o p t i o n > ) ) ;
formElements = (
formElements = (
< >
< >
< input type = "hidden" name = "_csrf" value = { csrf } / >
< td >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "btn btn-success" type = "submit" value = "+" / >
< select className = "form-select mx-3" name = "key" defaultValue = "" required >
< / t d >
< option value = "" / >
< td >
{ domainSelectOptions }
< select className = "form-select" name = "key" defaultValue = "" required >
< / s e l e c t >
< option value = "" / >
{ domainSelectOptions }
< / s e l e c t >
< / t d >
{
{
( process . env . NEXT _PUBLIC _CUSTOM _BACKENDS _ENABLED && mapInfo . name === "hosts" ) &&
( process . env . NEXT _PUBLIC _CUSTOM _BACKENDS _ENABLED && mapInfo . name === "hosts" ) &&
< input
< td >
className = "form-control ml-2"
< input
type = "text"
className = "form-control"
name = "value"
type = "text"
placeholder = "backend ip:port"
name = "value"
required
placeholder = "backend ip:port"
/ >
required
/ >
< / t d >
}
}
< / >
< / >
) ;
) ;
@ -146,12 +166,15 @@ const MapPage = (props) => {
const domainSelectOptions = inactiveDomains . map ( ( d , i ) => ( < option key = { 'option' + i } value = { d } > { d } < / o p t i o n > ) ) ;
const domainSelectOptions = inactiveDomains . map ( ( d , i ) => ( < option key = { 'option' + i } value = { d } > { d } < / o p t i o n > ) ) ;
formElements = (
formElements = (
< >
< >
< input type = "hidden" name = "_csrf" value = { csrf } / >
< td >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "btn btn-success" type = "submit" value = "+" / >
< select className = "form-select mx-3" name = "key" defaultValue = "" required >
< / t d >
< option value = "" / >
< td >
{ domainSelectOptions }
< select className = "form-select" name = "key" defaultValue = "" required >
< / s e l e c t >
< option value = "" / >
{ domainSelectOptions }
< / s e l e c t >
< / t d >
< / >
< / >
) ;
) ;
break ;
break ;
@ -160,9 +183,12 @@ const MapPage = (props) => {
case "whitelist" :
case "whitelist" :
formElements = (
formElements = (
< >
< >
< input type = "hidden" name = "_csrf" value = { csrf } / >
< td >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "form-control mx-3" type = "text" name = "key" placeholder = "ip or subnet" required / >
< / t d >
< td >
< input className = "form-control" type = "text" name = "key" placeholder = "ip or subnet" required / >
< / t d >
< / >
< / >
) ;
) ;
break ;
break ;
@ -170,10 +196,15 @@ const MapPage = (props) => {
case "rewrite" :
case "rewrite" :
formElements = (
formElements = (
< >
< >
< input type = "hidden" name = "_csrf" value = { csrf } / >
< td >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "btn btn-success" type = "submit" value = "+" / >
< input className = "form-control mx-3" type = "text" name = "key" placeholder = "domain" required / >
< / t d >
< input className = "form-control mx-3" type = "text" name = "value" placeholder = "domain or domain/path" required / >
< td >
< input className = "form-control" type = "text" name = "key" placeholder = "domain" required / >
< / t d >
< td >
< input className = "form-control" type = "text" name = "value" placeholder = "domain or domain/path" required / >
< / t d >
< / >
< / >
) ;
) ;
break ;
break ;
@ -196,14 +227,14 @@ const MapPage = (props) => {
< / h 5 >
< / h 5 >
{ /* Map table */ }
{ /* Map table */ }
< div className = "table-responsive" >
< div className = "table-responsive w-100" >
< table className = "table text-nowrap m-1" >
< form onSubmit = { addToMap } className = "d-flex" action = { ` /forms/map/ ${ mapInfo . name } /add ` } method = "post" >
< tbody >
< table className = "table text-nowrap mb-0" >
< tbody >
{ /* header row */ }
{ /* header row */ }
{ mapRows . length > 0 && (
< tr >
< tr >
< th / >
< th style = { { width : 0 } } / >
< th >
< th >
{ mapInfo . columnNames [ 0 ] }
{ mapInfo . columnNames [ 0 ] }
< / t h >
< / t h >
@ -212,22 +243,19 @@ const MapPage = (props) => {
{ x }
{ x }
< / t h >
< / t h >
) ) }
) ) }
< / t r >
< / t r >
) }
{ mapRows }
{ mapRows }
{ /* Add new row form */ }
{ /* Add new row form */ }
< tr className = "align-middle" >
< tr className = "align-middle" >
< td className = "col-1 text-center" colSpan = { mapInfo . columnNames . length + ( showValues ? 1 : 0 ) } >
{ formElements }
< form onSubmit = { addToMap } className = "d-flex" action = { ` /forms/map/ ${ mapInfo . name } /add ` } method = "post" >
< / t r >
{ formElements }
< / f o r m >
< / t d >
< / t r >
< / t b o d y >
< / t b o d y >
< / t a b l e >
< / t a b l e >
< / f o r m >
< / d i v >
< / d i v >
{ /* back to account */ }
{ /* back to account */ }