Nodes in boundary

how can I find the indixs of nodes in the boundary of mesh in (2d)

I build a small macro to get the list of of on some border but no all, this border must be be no close.

include “ExtractDofsonBorder.idp”
mesh Th = square(20,20,[xpi,piy]);
real c = 0.5;
// the exact solut
func uex = sin(x+c)sin(y);
func f = -2

fespace Vh(Th,P1);

int[int] dof2,dof4;
// get the list od dof on 2 border and 4 border
ExtractDofsonBorder(2,Vh,dof2,1)// sens of dof2
ExtractDofsonBorder(4,Vh,dof4,-1)// reverse sens of dof2
assert(dof2.n == dof4.n);